From 678a8565aaf838ffed0764b891b05e244b200d09 Mon Sep 17 00:00:00 2001 From: Ty Conner Date: Thu, 4 May 2023 15:29:27 -0400 Subject: [PATCH 01/22] Switch to System.Text.Json Removed Newtonsoft.Json and DouglasCrockford.JsMin --- Source/ACE.Adapter/ACE.Adapter.csproj | 8 +- Source/ACE.Adapter/GDLE/GDLELoader.cs | 41 ++++--- .../GDLE/Models/BoolRequirement.cs | 3 - .../ACE.Adapter/GDLE/Models/CreateOffset.cs | 11 +- .../ACE.Adapter/GDLE/Models/DIDRequirement.cs | 3 - Source/ACE.Adapter/GDLE/Models/Encounter.cs | 6 +- Source/ACE.Adapter/GDLE/Models/Event.cs | 6 +- Source/ACE.Adapter/GDLE/Models/EventValue.cs | 8 +- .../GDLE/Models/FloatRequirement.cs | 3 - .../ACE.Adapter/GDLE/Models/IIDRequirement.cs | 3 - .../ACE.Adapter/GDLE/Models/IntRequirement.cs | 3 - .../ACE.Adapter/GDLE/Models/LandblockValue.cs | 2 - Source/ACE.Adapter/GDLE/Models/MetaSpell.cs | 6 +- Source/ACE.Adapter/GDLE/Models/Metadata.cs | 3 +- Source/ACE.Adapter/GDLE/Models/Recipe.cs | 55 +++++---- .../GDLE/Models/RecipePrecursor.cs | 2 - Source/ACE.Adapter/GDLE/Models/Region.cs | 10 +- Source/ACE.Adapter/GDLE/Models/Spell.cs | 104 +++++++++--------- .../ACE.Adapter/GDLE/Models/SpellBaseHash.cs | 6 +- Source/ACE.Adapter/GDLE/Models/SpellTable.cs | 5 +- Source/ACE.Adapter/GDLE/Models/SpellValue.cs | 49 ++++----- Source/ACE.Adapter/GDLE/Models/Spells.cs | 4 +- Source/ACE.Adapter/GDLE/Models/StatMod.cs | 8 +- Source/ACE.Adapter/GDLE/Models/TerrainData.cs | 6 +- .../GDLE/Models/WieldedTreasure.cs | 36 +++--- .../GDLE/Models/WieldedTreasureTable.cs | 6 +- Source/ACE.Adapter/GDLE/Models/WorldSpawns.cs | 7 +- .../Lifestoned/LifestonedConverter.cs | 20 ++-- .../Lifestoned/LifestonedLoader.cs | 6 +- Source/ACE.Common/ACE.Common.csproj | 3 +- Source/ACE.Common/AccountDefaults.cs | 23 +--- Source/ACE.Common/ConfigManager.cs | 7 +- Source/ACE.Common/DatabaseConfiguration.cs | 27 ++++- Source/ACE.Common/GameConfiguration.cs | 81 ++++++++++---- Source/ACE.Common/MySqlConfiguration.cs | 10 +- Source/ACE.Common/NetworkSettings.cs | 22 +--- Source/ACE.Common/OfflineConfiguration.cs | 50 ++------- Source/ACE.Common/PreloadedLandblock.cs | 13 +-- Source/ACE.Common/ThreadConfiguration.cs | 19 +--- .../ACE.Server.Tests/ACE.Server.Tests.csproj | 1 - Source/ACE.Server/ACE.Server.csproj | 1 - .../Handlers/DeveloperContentCommands.cs | 20 ++-- .../Entity/StarterGearConfiguration.cs | 6 +- Source/ACE.Server/Entity/StarterGearSkill.cs | 14 +-- Source/ACE.Server/Entity/StarterHeritage.cs | 10 +- Source/ACE.Server/Entity/StarterItem.cs | 6 +- Source/ACE.Server/Entity/StarterSpell.cs | 9 +- .../Factories/StarterGearFactory.cs | 35 +++++- .../ACE.Server/Managers/RecipeManager_New.cs | 5 +- Source/ACE.Server/Program_BinUpdates.cs | 19 +--- Source/ACE.Server/Program_DbUpdates.cs | 13 +-- Source/ACE.Server/Program_Setup.cs | 28 ++--- 52 files changed, 418 insertions(+), 434 deletions(-) diff --git a/Source/ACE.Adapter/ACE.Adapter.csproj b/Source/ACE.Adapter/ACE.Adapter.csproj index 8e91e01a02..a941156e15 100644 --- a/Source/ACE.Adapter/ACE.Adapter.csproj +++ b/Source/ACE.Adapter/ACE.Adapter.csproj @@ -16,10 +16,6 @@ git - - - - @@ -38,4 +34,8 @@ + + + + diff --git a/Source/ACE.Adapter/GDLE/GDLELoader.cs b/Source/ACE.Adapter/GDLE/GDLELoader.cs index 50678fd340..47dd0912c1 100644 --- a/Source/ACE.Adapter/GDLE/GDLELoader.cs +++ b/Source/ACE.Adapter/GDLE/GDLELoader.cs @@ -2,10 +2,9 @@ using System.Collections.Generic; using System.IO; using System.Linq; +using System.Text.Json; using System.Threading.Tasks; -using Newtonsoft.Json; - using ACE.Database.Models.World; namespace ACE.Adapter.GDLE @@ -18,7 +17,7 @@ public static bool TryLoadLandblock(string file, out Models.Landblock result) { var fileText = File.ReadAllText(file); - result = JsonConvert.DeserializeObject(fileText); + result = JsonSerializer.Deserialize(fileText); return true; } @@ -60,7 +59,7 @@ public static bool TryLoadWorldSpawns(string file, out Models.WorldSpawns result { var fileText = File.ReadAllText(file); - result = JsonConvert.DeserializeObject(fileText); + result = JsonSerializer.Deserialize(fileText); return true; } @@ -189,7 +188,7 @@ public static bool TryLoadWorldSpawnsConverted(string file, out List(fileText); + var gdleModel = JsonSerializer.Deserialize(fileText); if (gdleModel.Landblocks == null) @@ -219,7 +218,7 @@ public static bool TryLoadEvents(string file, out List results) { var fileText = File.ReadAllText(file); - results = JsonConvert.DeserializeObject>(fileText); + results = JsonSerializer.Deserialize>(fileText); return true; } @@ -236,7 +235,7 @@ public static bool TryLoadEventsConverted(string file, out List results) { var fileText = File.ReadAllText(file); - var gdleModel = JsonConvert.DeserializeObject>(fileText); + var gdleModel = JsonSerializer.Deserialize>(fileText); results = new List(); @@ -262,7 +261,7 @@ public static bool TryLoadQuest(string file, out Models.Quest result) { var fileText = File.ReadAllText(file); - result = JsonConvert.DeserializeObject(fileText); + result = JsonSerializer.Deserialize(fileText); return true; } @@ -279,7 +278,7 @@ public static bool TryLoadQuests(string file, out List results) { var fileText = File.ReadAllText(file); - results = JsonConvert.DeserializeObject>(fileText); + results = JsonSerializer.Deserialize>(fileText); return true; } @@ -296,7 +295,7 @@ public static bool TryLoadQuestsConverted(string file, out List results) { var fileText = File.ReadAllText(file); - var gdleModel = JsonConvert.DeserializeObject>(fileText); + var gdleModel = JsonSerializer.Deserialize>(fileText); results = new List(); @@ -323,7 +322,7 @@ public static bool TryLoadSpells(string file, out Models.Spells result) { var fileText = File.ReadAllText(file); - result = JsonConvert.DeserializeObject(fileText); + result = JsonSerializer.Deserialize(fileText); return true; } @@ -340,7 +339,7 @@ public static bool TryLoadSpellsConverted(string file, out List results) { var fileText = File.ReadAllText(file); - var gdleModel = JsonConvert.DeserializeObject(fileText); + var gdleModel = JsonSerializer.Deserialize(fileText); results = new List(); @@ -366,7 +365,7 @@ public static bool TryLoadRecipe(string file, out Models.Recipe result) { var fileText = File.ReadAllText(file); - result = JsonConvert.DeserializeObject(fileText); + result = JsonSerializer.Deserialize(fileText); return true; } @@ -383,7 +382,7 @@ public static bool TryLoadRecipeCombined(string file, out Models.RecipeCombined { var fileText = File.ReadAllText(file); - result = JsonConvert.DeserializeObject(fileText); + result = JsonSerializer.Deserialize(fileText); return true; } @@ -469,7 +468,7 @@ public static bool TryLoadRecipesConverted(string file, out List results { var fileText = File.ReadAllText(file); - var gdleModel = JsonConvert.DeserializeObject>(fileText); + var gdleModel = JsonSerializer.Deserialize>(fileText); results = new List(); @@ -495,7 +494,7 @@ public static bool TryLoadRecipePrecursors(string file, out List>(fileText); + results = JsonSerializer.Deserialize>(fileText); return true; } @@ -512,7 +511,7 @@ public static bool TryLoadRecipePrecursorsConverted(string file, out List>(fileText); + var gdleModel = JsonSerializer.Deserialize>(fileText); results = new List(); @@ -538,7 +537,7 @@ public static bool TryLoadRegion(string file, out Models.Region result) { var fileText = File.ReadAllText(file); - result = JsonConvert.DeserializeObject(fileText); + result = JsonSerializer.Deserialize(fileText); return true; } @@ -555,7 +554,7 @@ public static bool TryLoadTerrainData(string file, out List { var fileText = File.ReadAllText(file); - results = JsonConvert.DeserializeObject>(fileText); + results = JsonSerializer.Deserialize>(fileText); return true; } @@ -572,7 +571,7 @@ public static bool TryLoadWieldedTreasureTable(string file, out List>(fileText); + results = JsonSerializer.Deserialize>(fileText); return true; } @@ -589,7 +588,7 @@ public static bool TryLoadWieldedTreasureTableConverted(string file, out List>(fileText); + var gdleModel = JsonSerializer.Deserialize>(fileText); results = new List(); diff --git a/Source/ACE.Adapter/GDLE/Models/BoolRequirement.cs b/Source/ACE.Adapter/GDLE/Models/BoolRequirement.cs index af74e8c23f..2f065ff72a 100644 --- a/Source/ACE.Adapter/GDLE/Models/BoolRequirement.cs +++ b/Source/ACE.Adapter/GDLE/Models/BoolRequirement.cs @@ -1,15 +1,12 @@ -using Newtonsoft.Json; namespace ACE.Adapter.GDLE.Models { public class BoolRequirement { - [JsonProperty(NullValueHandling = NullValueHandling.Ignore)] public int? Unknown { get; set; } public int OperationType { get; set; } - [JsonProperty(NullValueHandling = NullValueHandling.Ignore)] public string Message { get; set; } public int Stat { get; set; } diff --git a/Source/ACE.Adapter/GDLE/Models/CreateOffset.cs b/Source/ACE.Adapter/GDLE/Models/CreateOffset.cs index d85036d861..322adb1092 100644 --- a/Source/ACE.Adapter/GDLE/Models/CreateOffset.cs +++ b/Source/ACE.Adapter/GDLE/Models/CreateOffset.cs @@ -1,20 +1,19 @@ - -using Newtonsoft.Json; +using System.Text.Json.Serialization; namespace ACE.Adapter.GDLE.Models { public class CreateOffset { - [JsonProperty("x")] + [JsonPropertyName("x")] public double X { get; set; } - [JsonProperty("y")] + [JsonPropertyName("y")] public double Y { get; set; } - [JsonProperty("z")] + [JsonPropertyName("z")] public double Z { get; set; } - [JsonProperty("w", NullValueHandling = NullValueHandling.Ignore)] + [JsonPropertyName("w")] public double? W { get; set; } } } diff --git a/Source/ACE.Adapter/GDLE/Models/DIDRequirement.cs b/Source/ACE.Adapter/GDLE/Models/DIDRequirement.cs index 0d551a4a3c..93a55fd204 100644 --- a/Source/ACE.Adapter/GDLE/Models/DIDRequirement.cs +++ b/Source/ACE.Adapter/GDLE/Models/DIDRequirement.cs @@ -1,15 +1,12 @@ -using Newtonsoft.Json; namespace ACE.Adapter.GDLE.Models { public class DIDRequirement { - [JsonProperty(NullValueHandling = NullValueHandling.Ignore)] public int? Unknown { get; set; } public int OperationType { get; set; } - [JsonProperty(NullValueHandling = NullValueHandling.Ignore)] public string Message { get; set; } public int Stat { get; set; } diff --git a/Source/ACE.Adapter/GDLE/Models/Encounter.cs b/Source/ACE.Adapter/GDLE/Models/Encounter.cs index 7aa708c101..6dd32ec1f0 100644 --- a/Source/ACE.Adapter/GDLE/Models/Encounter.cs +++ b/Source/ACE.Adapter/GDLE/Models/Encounter.cs @@ -1,15 +1,15 @@ -using Newtonsoft.Json; using System.Collections.Generic; +using System.Text.Json.Serialization; namespace ACE.Adapter.GDLE.Models { public class Encounter { - [JsonProperty("key")] + [JsonPropertyName("key")] public uint Key { get; set; } - [JsonProperty("value")] + [JsonPropertyName("value")] public List Value { get; set; } } } diff --git a/Source/ACE.Adapter/GDLE/Models/Event.cs b/Source/ACE.Adapter/GDLE/Models/Event.cs index 29c4ccb07e..4a102a39ba 100644 --- a/Source/ACE.Adapter/GDLE/Models/Event.cs +++ b/Source/ACE.Adapter/GDLE/Models/Event.cs @@ -1,14 +1,14 @@ -using Newtonsoft.Json; +using System.Text.Json.Serialization; namespace ACE.Adapter.GDLE.Models { public class Event { - [JsonProperty("key")] + [JsonPropertyName("key")] public string Key { get; set; } - [JsonProperty("value")] + [JsonPropertyName("value")] public EventValue Value { get; set; } } } diff --git a/Source/ACE.Adapter/GDLE/Models/EventValue.cs b/Source/ACE.Adapter/GDLE/Models/EventValue.cs index ee047329e6..abe9ce271c 100644 --- a/Source/ACE.Adapter/GDLE/Models/EventValue.cs +++ b/Source/ACE.Adapter/GDLE/Models/EventValue.cs @@ -1,17 +1,17 @@ -using Newtonsoft.Json; +using System.Text.Json.Serialization; namespace ACE.Adapter.GDLE.Models { public class EventValue { - [JsonProperty("startTime")] + [JsonPropertyName("startTime")] public int StartTime { get; set; } - [JsonProperty("endTime")] + [JsonPropertyName("endTime")] public int EndTime { get; set; } - [JsonProperty("eventState")] + [JsonPropertyName("eventState")] public int EventState { get; set; } } } diff --git a/Source/ACE.Adapter/GDLE/Models/FloatRequirement.cs b/Source/ACE.Adapter/GDLE/Models/FloatRequirement.cs index ae43a85f15..ee0a7755df 100644 --- a/Source/ACE.Adapter/GDLE/Models/FloatRequirement.cs +++ b/Source/ACE.Adapter/GDLE/Models/FloatRequirement.cs @@ -1,15 +1,12 @@ -using Newtonsoft.Json; namespace ACE.Adapter.GDLE.Models { public class FloatRequirement { - [JsonProperty(NullValueHandling = NullValueHandling.Ignore)] public int? Unknown { get; set; } public int OperationType { get; set; } - [JsonProperty(NullValueHandling = NullValueHandling.Ignore)] public string Message { get; set; } public int Stat { get; set; } diff --git a/Source/ACE.Adapter/GDLE/Models/IIDRequirement.cs b/Source/ACE.Adapter/GDLE/Models/IIDRequirement.cs index 1a977978c6..b0fffe106d 100644 --- a/Source/ACE.Adapter/GDLE/Models/IIDRequirement.cs +++ b/Source/ACE.Adapter/GDLE/Models/IIDRequirement.cs @@ -1,15 +1,12 @@ -using Newtonsoft.Json; namespace ACE.Adapter.GDLE.Models { public class IIDRequirement { - [JsonProperty(NullValueHandling = NullValueHandling.Ignore)] public int? Unknown { get; set; } public int OperationType { get; set; } - [JsonProperty(NullValueHandling = NullValueHandling.Ignore)] public string Message { get; set; } public int Stat { get; set; } diff --git a/Source/ACE.Adapter/GDLE/Models/IntRequirement.cs b/Source/ACE.Adapter/GDLE/Models/IntRequirement.cs index 14c162f3fb..bd3035d524 100644 --- a/Source/ACE.Adapter/GDLE/Models/IntRequirement.cs +++ b/Source/ACE.Adapter/GDLE/Models/IntRequirement.cs @@ -1,15 +1,12 @@ -using Newtonsoft.Json; namespace ACE.Adapter.GDLE.Models { public class IntRequirement { - [JsonProperty(NullValueHandling = NullValueHandling.Ignore)] public int? Unknown { get; set; } public int OperationType { get; set; } - [JsonProperty(NullValueHandling = NullValueHandling.Ignore)] public string Message { get; set; } public int Stat { get; set; } diff --git a/Source/ACE.Adapter/GDLE/Models/LandblockValue.cs b/Source/ACE.Adapter/GDLE/Models/LandblockValue.cs index 7e12719216..83b4687d3e 100644 --- a/Source/ACE.Adapter/GDLE/Models/LandblockValue.cs +++ b/Source/ACE.Adapter/GDLE/Models/LandblockValue.cs @@ -1,11 +1,9 @@ using System.Collections.Generic; -using Newtonsoft.Json; namespace ACE.Adapter.GDLE.Models { public class LandblockValue { - [JsonProperty(NullValueHandling = NullValueHandling.Ignore)] public List links { get; set; } public List weenies { get; set; } } diff --git a/Source/ACE.Adapter/GDLE/Models/MetaSpell.cs b/Source/ACE.Adapter/GDLE/Models/MetaSpell.cs index 8590034db5..d7ad564de2 100644 --- a/Source/ACE.Adapter/GDLE/Models/MetaSpell.cs +++ b/Source/ACE.Adapter/GDLE/Models/MetaSpell.cs @@ -1,14 +1,14 @@ -using Newtonsoft.Json; +using System.Text.Json.Serialization; namespace ACE.Adapter.GDLE.Models { public class MetaSpell { - [JsonProperty("sp_type")] + [JsonPropertyName("sp_type")] public int Type { get; set; } - [JsonProperty("spell")] + [JsonPropertyName("spell")] public Spell Spell { get; set; } } } diff --git a/Source/ACE.Adapter/GDLE/Models/Metadata.cs b/Source/ACE.Adapter/GDLE/Models/Metadata.cs index 37ee6c1479..f336aea2b7 100644 --- a/Source/ACE.Adapter/GDLE/Models/Metadata.cs +++ b/Source/ACE.Adapter/GDLE/Models/Metadata.cs @@ -1,7 +1,6 @@ using System; using System.Collections.Generic; - -using Newtonsoft.Json; +using System.Text.Json.Serialization; using Lifestoned.DataModel.Gdle; using Lifestoned.DataModel.Shared; diff --git a/Source/ACE.Adapter/GDLE/Models/Recipe.cs b/Source/ACE.Adapter/GDLE/Models/Recipe.cs index dfd03c9449..2a45703a6d 100644 --- a/Source/ACE.Adapter/GDLE/Models/Recipe.cs +++ b/Source/ACE.Adapter/GDLE/Models/Recipe.cs @@ -1,87 +1,86 @@ using System.Collections.Generic; - -using Newtonsoft.Json; +using System.Text.Json.Serialization; namespace ACE.Adapter.GDLE.Models { public class Recipe { - [JsonProperty("RecipeID")] + [JsonPropertyName("RecipeID")] public uint RecipeId { get; set; } - [JsonProperty("Skill")] + [JsonPropertyName("Skill")] public uint Skill { get; set; } - [JsonProperty("SkillCheckFormulaType")] + [JsonPropertyName("SkillCheckFormulaType")] public int SkillCheckFormulaType { get; set; } - [JsonProperty("DataID")] + [JsonPropertyName("DataID")] public uint DataId { get; set; } - [JsonProperty("Difficulty")] + [JsonPropertyName("Difficulty")] public uint Difficulty { get; set; } - [JsonProperty("SuccessWcid")] + [JsonPropertyName("SuccessWcid")] public uint SuccessWcid { get; set; } - [JsonProperty("SuccessAmount")] + [JsonPropertyName("SuccessAmount")] public uint SuccessAmount { get; set; } - [JsonProperty("SuccessMessage")] + [JsonPropertyName("SuccessMessage")] public string SuccessMessage { get; set; } - [JsonProperty("SuccessConsumeTargetAmount")] + [JsonPropertyName("SuccessConsumeTargetAmount")] public uint SuccessConsumeTargetAmount { get; set; } - [JsonProperty("SuccessConsumeTargetChance")] + [JsonPropertyName("SuccessConsumeTargetChance")] public double SuccessConsumeTargetChance { get; set; } - [JsonProperty("SuccessConsumeTargetMessage")] + [JsonPropertyName("SuccessConsumeTargetMessage")] public string SuccessConsumeTargetMessage { get; set; } - [JsonProperty("SuccessConsumeToolAmount")] + [JsonPropertyName("SuccessConsumeToolAmount")] public uint SuccessConsumeToolAmount { get; set; } - [JsonProperty("SuccessConsumeToolChance")] + [JsonPropertyName("SuccessConsumeToolChance")] public double SuccessConsumeToolChance { get; set; } - [JsonProperty("SuccessConsumeToolMessage")] + [JsonPropertyName("SuccessConsumeToolMessage")] public string SuccessConsumeToolMessage { get; set; } - [JsonProperty("FailWcid")] + [JsonPropertyName("FailWcid")] public uint FailWcid { get; set; } - [JsonProperty("FailAmount")] + [JsonPropertyName("FailAmount")] public uint FailAmount { get; set; } - [JsonProperty("FailMessage")] + [JsonPropertyName("FailMessage")] public string FailMessage { get; set; } - [JsonProperty("FailureConsumeTargetAmount")] + [JsonPropertyName("FailureConsumeTargetAmount")] public uint FailureConsumeTargetAmount { get; set; } - [JsonProperty("FailureConsumeTargetChance")] + [JsonPropertyName("FailureConsumeTargetChance")] public double FailureConsumeTargetChance { get; set; } - [JsonProperty("FailureConsumeTargetMessage")] + [JsonPropertyName("FailureConsumeTargetMessage")] public string FailureConsumeTargetMessage { get; set; } - [JsonProperty("FailureConsumeToolAmount")] + [JsonPropertyName("FailureConsumeToolAmount")] public uint FailureConsumeToolAmount { get; set; } - [JsonProperty("FailureConsumeToolChance")] + [JsonPropertyName("FailureConsumeToolChance")] public double FailureConsumeToolChance { get; set; } - [JsonProperty("FailureConsumeToolMessage")] + [JsonPropertyName("FailureConsumeToolMessage")] public string FailureConsumeToolMessage { get; set; } - [JsonProperty("Unknown")] + [JsonPropertyName("Unknown")] public int Unknown { get; set; } - [JsonProperty("Mods")] + [JsonPropertyName("Mods")] public List Mods { get; set; } - [JsonProperty("Requirements")] + [JsonPropertyName("Requirements")] public List Requirements { get; set; } } } diff --git a/Source/ACE.Adapter/GDLE/Models/RecipePrecursor.cs b/Source/ACE.Adapter/GDLE/Models/RecipePrecursor.cs index 6abc8921f0..69d766e3f5 100644 --- a/Source/ACE.Adapter/GDLE/Models/RecipePrecursor.cs +++ b/Source/ACE.Adapter/GDLE/Models/RecipePrecursor.cs @@ -1,4 +1,3 @@ -using Newtonsoft.Json; namespace ACE.Adapter.GDLE.Models { @@ -8,7 +7,6 @@ public class RecipePrecursor public uint Target { get; set; } - [JsonProperty(NullValueHandling = NullValueHandling.Ignore)] public uint? RecipeId { get; set; } } } diff --git a/Source/ACE.Adapter/GDLE/Models/Region.cs b/Source/ACE.Adapter/GDLE/Models/Region.cs index 14795806cc..61454770ef 100644 --- a/Source/ACE.Adapter/GDLE/Models/Region.cs +++ b/Source/ACE.Adapter/GDLE/Models/Region.cs @@ -1,21 +1,21 @@ -using Newtonsoft.Json; using System.Collections.Generic; +using System.Text.Json.Serialization; namespace ACE.Adapter.GDLE.Models { public class Region { - [JsonProperty("encounterMap")] + [JsonPropertyName("encounterMap")] public List EncounterMap { get; set; } - [JsonProperty("encounters")] + [JsonPropertyName("encounters")] public Encounter[] Encounters { get; set; } - [JsonProperty("tableCount")] + [JsonPropertyName("tableCount")] public int TableCount { get; set; } - [JsonProperty("tableSize")] + [JsonPropertyName("tableSize")] public int TableSize { get; set; } } } diff --git a/Source/ACE.Adapter/GDLE/Models/Spell.cs b/Source/ACE.Adapter/GDLE/Models/Spell.cs index cd46a24468..460fbfb567 100644 --- a/Source/ACE.Adapter/GDLE/Models/Spell.cs +++ b/Source/ACE.Adapter/GDLE/Models/Spell.cs @@ -1,161 +1,161 @@ -using Newtonsoft.Json; +using System.Text.Json.Serialization; namespace ACE.Adapter.GDLE.Models { public class Spell { - [JsonProperty("degrade_limit", NullValueHandling = NullValueHandling.Ignore)] + [JsonPropertyName("degrade_limit")] public double? DegradeLimit { get; set; } - [JsonProperty("degrade_modifier", NullValueHandling = NullValueHandling.Ignore)] + [JsonPropertyName("degrade_modifier")] public uint? DegradeModifier { get; set; } - [JsonProperty("duration", NullValueHandling = NullValueHandling.Ignore)] + [JsonPropertyName("duration")] public double? Duration { get; set; } - [JsonProperty("smod", NullValueHandling = NullValueHandling.Ignore)] + [JsonPropertyName("smod")] public StatMod StatMod { get; set; } - [JsonProperty("spellCategory", NullValueHandling = NullValueHandling.Ignore)] + [JsonPropertyName("spellCategory")] public uint? SpellCategory { get; set; } - [JsonProperty("spell_id")] + [JsonPropertyName("spell_id")] public uint SpellId { get; set; } - [JsonProperty("boost", NullValueHandling = NullValueHandling.Ignore)] + [JsonPropertyName("boost")] public int? Boost { get; set; } - [JsonProperty("boostVariance", NullValueHandling = NullValueHandling.Ignore)] + [JsonPropertyName("boostVariance")] public int? BoostVariance { get; set; } - [JsonProperty("dt", NullValueHandling = NullValueHandling.Ignore)] + [JsonPropertyName("dt")] public int? DamageType { get; set; } - [JsonProperty("bitfield", NullValueHandling = NullValueHandling.Ignore)] + [JsonPropertyName("bitfield")] public uint? Bitfield { get; set; } - [JsonProperty("dest", NullValueHandling = NullValueHandling.Ignore)] + [JsonPropertyName("dest")] public int? Dest { get; set; } - [JsonProperty("lossPercent", NullValueHandling = NullValueHandling.Ignore)] + [JsonPropertyName("lossPercent")] public double? LossPercent { get; set; } - [JsonProperty("maxBoostAllowed", NullValueHandling = NullValueHandling.Ignore)] + [JsonPropertyName("maxBoostAllowed")] public int? MaxBoostAllowed { get; set; } - [JsonProperty("proportion", NullValueHandling = NullValueHandling.Ignore)] + [JsonPropertyName("proportion")] public double? Proportion { get; set; } - [JsonProperty("sourceLoss", NullValueHandling = NullValueHandling.Ignore)] + [JsonPropertyName("sourceLoss")] public int? SourceLoss { get; set; } - [JsonProperty("src", NullValueHandling = NullValueHandling.Ignore)] + [JsonPropertyName("src")] public int? Source { get; set; } - [JsonProperty("transferCap", NullValueHandling = NullValueHandling.Ignore)] + [JsonPropertyName("transferCap")] public int? TransferCap { get; set; } - [JsonProperty("bNonTracking", NullValueHandling = NullValueHandling.Ignore)] + [JsonPropertyName("bNonTracking")] public bool? NonTracking { get; set; } - [JsonProperty("baseIntensity", NullValueHandling = NullValueHandling.Ignore)] + [JsonPropertyName("baseIntensity")] public int? BaseIntensity { get; set; } - [JsonProperty("createOffset", NullValueHandling = NullValueHandling.Ignore)] + [JsonPropertyName("createOffset")] public CreateOffset CreateOffset { get; set; } - [JsonProperty("critFreq", NullValueHandling = NullValueHandling.Ignore)] + [JsonPropertyName("critFreq")] public uint? CritFreq { get; set; } - [JsonProperty("critMultiplier", NullValueHandling = NullValueHandling.Ignore)] + [JsonPropertyName("critMultiplier")] public uint? CritMultiplier { get; set; } - [JsonProperty("defaultLaunchAngle", NullValueHandling = NullValueHandling.Ignore)] + [JsonPropertyName("defaultLaunchAngle")] public uint? DefaultLaunchAngle { get; set; } - [JsonProperty("dims", NullValueHandling = NullValueHandling.Ignore)] + [JsonPropertyName("dims")] public CreateOffset Dims { get; set; } - [JsonProperty("elementalModifier", NullValueHandling = NullValueHandling.Ignore)] + [JsonPropertyName("elementalModifier")] public uint? ElementalModifier { get; set; } - [JsonProperty("etype", NullValueHandling = NullValueHandling.Ignore)] + [JsonPropertyName("etype")] public uint? EType { get; set; } - [JsonProperty("ignoreMagicResist", NullValueHandling = NullValueHandling.Ignore)] + [JsonPropertyName("ignoreMagicResist")] public int? IgnoreMagicResist { get; set; } - [JsonProperty("imbuedEffect", NullValueHandling = NullValueHandling.Ignore)] + [JsonPropertyName("imbuedEffect")] public uint? ImbuedEffect { get; set; } - [JsonProperty("numProjectiles", NullValueHandling = NullValueHandling.Ignore)] + [JsonPropertyName("numProjectiles")] public int? NumProjectiles { get; set; } - [JsonProperty("numProjectilesVariance", NullValueHandling = NullValueHandling.Ignore)] + [JsonPropertyName("numProjectilesVariance")] public double? NumProjectilesVariance { get; set; } - [JsonProperty("padding", NullValueHandling = NullValueHandling.Ignore)] + [JsonPropertyName("padding")] public CreateOffset Padding { get; set; } - [JsonProperty("peturbation", NullValueHandling = NullValueHandling.Ignore)] + [JsonPropertyName("peturbation")] public CreateOffset Peturbation { get; set; } - [JsonProperty("slayerCreatureType", NullValueHandling = NullValueHandling.Ignore)] + [JsonPropertyName("slayerCreatureType")] public int? SlayerCreatureType { get; set; } - [JsonProperty("slayerDamageBonus", NullValueHandling = NullValueHandling.Ignore)] + [JsonPropertyName("slayerDamageBonus")] public uint? SlayerDamageBonus { get; set; } - [JsonProperty("spreadAngle", NullValueHandling = NullValueHandling.Ignore)] + [JsonPropertyName("spreadAngle")] public uint? SpreadAngle { get; set; } - [JsonProperty("variance", NullValueHandling = NullValueHandling.Ignore)] + [JsonPropertyName("variance")] public int? Variance { get; set; } - [JsonProperty("verticalAngle", NullValueHandling = NullValueHandling.Ignore)] + [JsonPropertyName("verticalAngle")] public uint? VerticalAngle { get; set; } - [JsonProperty("wcid", NullValueHandling = NullValueHandling.Ignore)] + [JsonPropertyName("wcid")] public uint? Wcid { get; set; } - [JsonProperty("index", NullValueHandling = NullValueHandling.Ignore)] + [JsonPropertyName("index")] public int? Index { get; set; } - [JsonProperty("link", NullValueHandling = NullValueHandling.Ignore)] + [JsonPropertyName("link")] public int? Link { get; set; } - [JsonProperty("portal_lifetime", NullValueHandling = NullValueHandling.Ignore)] + [JsonPropertyName("portal_lifetime")] public uint? PortalLifetime { get; set; } - [JsonProperty("pos", NullValueHandling = NullValueHandling.Ignore)] + [JsonPropertyName("pos")] public Position Position { get; set; } - [JsonProperty("align", NullValueHandling = NullValueHandling.Ignore)] + [JsonPropertyName("align")] public int? Align { get; set; } - [JsonProperty("max_power", NullValueHandling = NullValueHandling.Ignore)] + [JsonPropertyName("max_power")] public int? MaxPower { get; set; } - [JsonProperty("min_power", NullValueHandling = NullValueHandling.Ignore)] + [JsonPropertyName("min_power")] public int? MinPower { get; set; } - [JsonProperty("number", NullValueHandling = NullValueHandling.Ignore)] + [JsonPropertyName("number")] public int? Number { get; set; } - [JsonProperty("number_variance", NullValueHandling = NullValueHandling.Ignore)] + [JsonPropertyName("number_variance")] public double? NumberVariance { get; set; } - [JsonProperty("power_variance", NullValueHandling = NullValueHandling.Ignore)] + [JsonPropertyName("power_variance")] public uint? PowerVariance { get; set; } - [JsonProperty("school", NullValueHandling = NullValueHandling.Ignore)] + [JsonPropertyName("school")] public uint? School { get; set; } - [JsonProperty("damage_ratio", NullValueHandling = NullValueHandling.Ignore)] + [JsonPropertyName("damage_ratio")] public double? DamageRatio { get; set; } - [JsonProperty("drain_percentage", NullValueHandling = NullValueHandling.Ignore)] + [JsonPropertyName("drain_percentage")] public double? DrainPercentage { get; set; } } } diff --git a/Source/ACE.Adapter/GDLE/Models/SpellBaseHash.cs b/Source/ACE.Adapter/GDLE/Models/SpellBaseHash.cs index 00165a28fb..d21421655f 100644 --- a/Source/ACE.Adapter/GDLE/Models/SpellBaseHash.cs +++ b/Source/ACE.Adapter/GDLE/Models/SpellBaseHash.cs @@ -1,14 +1,14 @@ -using Newtonsoft.Json; +using System.Text.Json.Serialization; namespace ACE.Adapter.GDLE.Models { public class SpellBaseHash { - [JsonProperty("key")] + [JsonPropertyName("key")] public uint Key { get; set; } - [JsonProperty("value")] + [JsonPropertyName("value")] public SpellValue Value { get; set; } } } diff --git a/Source/ACE.Adapter/GDLE/Models/SpellTable.cs b/Source/ACE.Adapter/GDLE/Models/SpellTable.cs index bafe849e50..0eacc13dfe 100644 --- a/Source/ACE.Adapter/GDLE/Models/SpellTable.cs +++ b/Source/ACE.Adapter/GDLE/Models/SpellTable.cs @@ -1,12 +1,11 @@ using System.Collections.Generic; - -using Newtonsoft.Json; +using System.Text.Json.Serialization; namespace ACE.Adapter.GDLE.Models { public class SpellTable { - [JsonProperty("spellBaseHash")] + [JsonPropertyName("spellBaseHash")] public List SpellBaseHash { get; set; } } } diff --git a/Source/ACE.Adapter/GDLE/Models/SpellValue.cs b/Source/ACE.Adapter/GDLE/Models/SpellValue.cs index 272a3fe879..08c417ae49 100644 --- a/Source/ACE.Adapter/GDLE/Models/SpellValue.cs +++ b/Source/ACE.Adapter/GDLE/Models/SpellValue.cs @@ -1,78 +1,77 @@ using System.Collections.Generic; - -using Newtonsoft.Json; +using System.Text.Json.Serialization; namespace ACE.Adapter.GDLE.Models { public class SpellValue { - [JsonProperty("base_mana")] + [JsonPropertyName("base_mana")] public uint BaseMana { get; set; } - [JsonProperty("base_range_constant")] + [JsonPropertyName("base_range_constant")] public double BaseRangeConstant { get; set; } - [JsonProperty("base_range_mod")] + [JsonPropertyName("base_range_mod")] public double BaseRangeMod { get; set; } - [JsonProperty("bitfield")] + [JsonPropertyName("bitfield")] public uint Bitfield { get; set; } - [JsonProperty("caster_effect")] + [JsonPropertyName("caster_effect")] public uint CasterEffect { get; set; } - [JsonProperty("category")] + [JsonPropertyName("category")] public uint Category { get; set; } - [JsonProperty("component_loss")] + [JsonPropertyName("component_loss")] public double ComponentLoss { get; set; } - [JsonProperty("desc")] + [JsonPropertyName("desc")] public string Desc { get; set; } - [JsonProperty("display_order")] + [JsonPropertyName("display_order")] public uint DisplayOrder { get; set; } - [JsonProperty("fizzle_effect")] + [JsonPropertyName("fizzle_effect")] public uint FizzleEffect { get; set; } - [JsonProperty("formula")] + [JsonPropertyName("formula")] public List Formula { get; set; } - [JsonProperty("formula_version")] + [JsonPropertyName("formula_version")] public uint FormulaVersion { get; set; } - [JsonProperty("iconID")] + [JsonPropertyName("iconID")] public uint IconId { get; set; } - [JsonProperty("mana_mod")] + [JsonPropertyName("mana_mod")] public uint ManaMod { get; set; } - [JsonProperty("meta_spell")] + [JsonPropertyName("meta_spell")] public MetaSpell MetaSpell { get; set; } - [JsonProperty("name")] + [JsonPropertyName("name")] public string Name { get; set; } - [JsonProperty("non_component_target_type")] + [JsonPropertyName("non_component_target_type")] public uint NonComponentTargetType { get; set; } - [JsonProperty("power")] + [JsonPropertyName("power")] public uint Power { get; set; } - [JsonProperty("recovery_amount")] + [JsonPropertyName("recovery_amount")] public uint RecoveryAmount { get; set; } - [JsonProperty("recovery_interval")] + [JsonPropertyName("recovery_interval")] public uint RecoveryInterval { get; set; } - [JsonProperty("school")] + [JsonPropertyName("school")] public int School { get; set; } - [JsonProperty("spell_economy_mod")] + [JsonPropertyName("spell_economy_mod")] public uint SpellEconomyMod { get; set; } - [JsonProperty("target_effect")] + [JsonPropertyName("target_effect")] public uint TargetEffect { get; set; } } } diff --git a/Source/ACE.Adapter/GDLE/Models/Spells.cs b/Source/ACE.Adapter/GDLE/Models/Spells.cs index b3dc2b1383..07c84c9f22 100644 --- a/Source/ACE.Adapter/GDLE/Models/Spells.cs +++ b/Source/ACE.Adapter/GDLE/Models/Spells.cs @@ -1,11 +1,11 @@ -using Newtonsoft.Json; +using System.Text.Json.Serialization; namespace ACE.Adapter.GDLE.Models { public class Spells { - [JsonProperty("table")] + [JsonPropertyName("table")] public SpellTable Table { get; set; } } } diff --git a/Source/ACE.Adapter/GDLE/Models/StatMod.cs b/Source/ACE.Adapter/GDLE/Models/StatMod.cs index 076600df63..46fbb22b41 100644 --- a/Source/ACE.Adapter/GDLE/Models/StatMod.cs +++ b/Source/ACE.Adapter/GDLE/Models/StatMod.cs @@ -1,17 +1,17 @@ -using Newtonsoft.Json; +using System.Text.Json.Serialization; namespace ACE.Adapter.GDLE.Models { public class StatMod { - [JsonProperty("key")] + [JsonPropertyName("key")] public uint Key { get; set; } - [JsonProperty("type")] + [JsonPropertyName("type")] public uint Type { get; set; } - [JsonProperty("val")] + [JsonPropertyName("val")] public double Val { get; set; } } } diff --git a/Source/ACE.Adapter/GDLE/Models/TerrainData.cs b/Source/ACE.Adapter/GDLE/Models/TerrainData.cs index 024f502947..45396004c0 100644 --- a/Source/ACE.Adapter/GDLE/Models/TerrainData.cs +++ b/Source/ACE.Adapter/GDLE/Models/TerrainData.cs @@ -1,15 +1,15 @@ -using Newtonsoft.Json; using System.Collections.Generic; +using System.Text.Json.Serialization; namespace ACE.Adapter.GDLE.Models { public class TerrainData { - [JsonProperty("key")] + [JsonPropertyName("key")] public uint Key { get; set; } - [JsonProperty("value")] + [JsonPropertyName("value")] public List Value { get; set; } } } diff --git a/Source/ACE.Adapter/GDLE/Models/WieldedTreasure.cs b/Source/ACE.Adapter/GDLE/Models/WieldedTreasure.cs index 3b13944937..49eb32da6f 100644 --- a/Source/ACE.Adapter/GDLE/Models/WieldedTreasure.cs +++ b/Source/ACE.Adapter/GDLE/Models/WieldedTreasure.cs @@ -1,59 +1,59 @@ -using Newtonsoft.Json; +using System.Text.Json.Serialization; namespace ACE.Adapter.GDLE.Models { public class WieldedTreasure { - [JsonProperty("continuesPreviousSet")] + [JsonPropertyName("continuesPreviousSet")] public bool ContinuesPreviousSet { get; set; } - [JsonProperty("setStart")] + [JsonPropertyName("setStart")] public bool SetStart { get; set; } - [JsonProperty("hasSubSet")] + [JsonPropertyName("hasSubSet")] public bool HasSubSet { get; set; } - [JsonProperty("probability")] + [JsonPropertyName("probability")] public float Probability { get; set; } - [JsonProperty("stackSize")] + [JsonPropertyName("stackSize")] public int StackSize { get; set; } - [JsonProperty("stackSizeVariance")] + [JsonPropertyName("stackSizeVariance")] public float StackSizeVariance { get; set; } - [JsonProperty("paletteId")] + [JsonPropertyName("paletteId")] public uint PaletteId { get; set; } - [JsonProperty("shade")] + [JsonPropertyName("shade")] public float Shade { get; set; } - [JsonProperty("unknown1")] + [JsonPropertyName("unknown1")] public uint Unknown1 { get; set; } - [JsonProperty("unknown3")] + [JsonPropertyName("unknown3")] public uint Unknown3 { get; set; } - [JsonProperty("unknown4")] + [JsonPropertyName("unknown4")] public uint Unknown4 { get; set; } - [JsonProperty("unknown5")] + [JsonPropertyName("unknown5")] public uint Unknown5 { get; set; } - [JsonProperty("unknown9")] + [JsonPropertyName("unknown9")] public uint Unknown9 { get; set; } - [JsonProperty("unknown10")] + [JsonPropertyName("unknown10")] public uint Unknown10 { get; set; } - [JsonProperty("unknown11")] + [JsonPropertyName("unknown11")] public uint Unknown11 { get; set; } - [JsonProperty("unknown12")] + [JsonPropertyName("unknown12")] public uint Unknown12 { get; set; } - [JsonProperty("weenieClassId")] + [JsonPropertyName("weenieClassId")] public uint WeenieClassId { get; set; } } } diff --git a/Source/ACE.Adapter/GDLE/Models/WieldedTreasureTable.cs b/Source/ACE.Adapter/GDLE/Models/WieldedTreasureTable.cs index 4e13a09e95..6d712ac11e 100644 --- a/Source/ACE.Adapter/GDLE/Models/WieldedTreasureTable.cs +++ b/Source/ACE.Adapter/GDLE/Models/WieldedTreasureTable.cs @@ -1,15 +1,15 @@ -using Newtonsoft.Json; using System.Collections.Generic; +using System.Text.Json.Serialization; namespace ACE.Adapter.GDLE.Models { public class WieldedTreasureTable { - [JsonProperty("key")] + [JsonPropertyName("key")] public uint Key { get; set; } - [JsonProperty("value")] + [JsonPropertyName("value")] public List Value { get; set; } } } diff --git a/Source/ACE.Adapter/GDLE/Models/WorldSpawns.cs b/Source/ACE.Adapter/GDLE/Models/WorldSpawns.cs index 25174b312b..2e8bae143b 100644 --- a/Source/ACE.Adapter/GDLE/Models/WorldSpawns.cs +++ b/Source/ACE.Adapter/GDLE/Models/WorldSpawns.cs @@ -1,15 +1,14 @@ using System.Collections.Generic; - -using Newtonsoft.Json; +using System.Text.Json.Serialization; namespace ACE.Adapter.GDLE.Models { public class WorldSpawns { - [JsonProperty("_version")] + [JsonPropertyName("_version")] public string Version { get; set; } - [JsonProperty("landblocks")] + [JsonPropertyName("landblocks")] public List Landblocks { get; set; } } } diff --git a/Source/ACE.Adapter/Lifestoned/LifestonedConverter.cs b/Source/ACE.Adapter/Lifestoned/LifestonedConverter.cs index dfe250ad26..eebf90dd11 100644 --- a/Source/ACE.Adapter/Lifestoned/LifestonedConverter.cs +++ b/Source/ACE.Adapter/Lifestoned/LifestonedConverter.cs @@ -1,9 +1,7 @@ using System; using System.Collections.Generic; using System.Linq; - -using Newtonsoft.Json; - +using System.Text.Json; using ACE.Adapter.Enum; using ACE.Database.Models.World; using ACE.Entity.Enum; @@ -1102,7 +1100,7 @@ public static bool TryConvertACEWeeniesToLSDJSON(List weenies, out List< { if (TryConvert(weenie, out var result)) { - results.Add(JsonConvert.SerializeObject(result)); + results.Add(JsonSerializer.Serialize(result, SerializerSettings)); } } @@ -1115,15 +1113,17 @@ public static bool TryConvertACEWeeniesToLSDJSON(List weenies, out List< } } - public static JsonSerializerSettings SerializerSettings = new JsonSerializerSettings(); + public static JsonSerializerOptions SerializerSettings = new JsonSerializerOptions(); static LifestonedConverter() { - //SerializerSettings.Converters.Add(new JavaScriptDateTimeConverter()); - SerializerSettings.NullValueHandling = NullValueHandling.Ignore; - SerializerSettings.DateFormatHandling = DateFormatHandling.IsoDateFormat; + ////SerializerSettings.Converters.Add(new JavaScriptDateTimeConverter()); + //SerializerSettings.NullValueHandling = NullValueHandling.Ignore; + //SerializerSettings.DateFormatHandling = DateFormatHandling.IsoDateFormat; + + //SerializerSettings.Formatting = Formatting.Indented; - SerializerSettings.Formatting = Formatting.Indented; + SerializerSettings.WriteIndented = true; } public static bool TryConvertACEWeenieToLSDJSON(Weenie weenie, out string result, out global::Lifestoned.DataModel.Gdle.Weenie lsdWeenie) @@ -1134,7 +1134,7 @@ public static bool TryConvertACEWeenieToLSDJSON(Weenie weenie, out string result { try { - result = JsonConvert.SerializeObject(lsdWeenie, SerializerSettings); + result = JsonSerializer.Serialize(lsdWeenie, SerializerSettings); } catch { diff --git a/Source/ACE.Adapter/Lifestoned/LifestonedLoader.cs b/Source/ACE.Adapter/Lifestoned/LifestonedLoader.cs index 6790ece718..d5e4770e31 100644 --- a/Source/ACE.Adapter/Lifestoned/LifestonedLoader.cs +++ b/Source/ACE.Adapter/Lifestoned/LifestonedLoader.cs @@ -3,8 +3,8 @@ using System.Collections.Generic; using System.IO; using System.Linq; +using System.Text.Json; using System.Threading.Tasks; -using Newtonsoft.Json; using ACE.Adapter.GDLE.Models; using ACE.Database.Models.World; @@ -19,7 +19,7 @@ public static bool TryLoadWeenie(string file, out global::Lifestoned.DataModel.G { var fileText = File.ReadAllText(file); - result = JsonConvert.DeserializeObject(fileText); + result = JsonSerializer.Deserialize(fileText); return true; } @@ -85,7 +85,7 @@ public static bool TryLoadWeenieConverted(string file, out Weenie result, bool c { var fileText = File.ReadAllText(file); - var lifestonedModel = JsonConvert.DeserializeObject(fileText); + var lifestonedModel = JsonSerializer.Deserialize(fileText); return LifestonedConverter.TryConvert(lifestonedModel, out result, correctForEnumShift); } diff --git a/Source/ACE.Common/ACE.Common.csproj b/Source/ACE.Common/ACE.Common.csproj index 3602be564f..47d8af0b7b 100644 --- a/Source/ACE.Common/ACE.Common.csproj +++ b/Source/ACE.Common/ACE.Common.csproj @@ -16,8 +16,7 @@ - - + diff --git a/Source/ACE.Common/AccountDefaults.cs b/Source/ACE.Common/AccountDefaults.cs index 1d970d13bc..2d0b39e7ae 100644 --- a/Source/ACE.Common/AccountDefaults.cs +++ b/Source/ACE.Common/AccountDefaults.cs @@ -1,47 +1,36 @@ -using Newtonsoft.Json; namespace ACE.Common { - public struct AccountDefaults + public class AccountDefaults { /// /// whether or not the server uses account level permissions or character level permissions (as AC retail did). for backwards compatibility, this is true /// by default. /// - [System.ComponentModel.DefaultValue(true)] - [JsonProperty(DefaultValueHandling = DefaultValueHandling.Populate)] - public bool OverrideCharacterPermissions { get; set; } + public bool OverrideCharacterPermissions { get; set; } = true; /// /// Default AccessLevel for new accounts. Used when accesslevel is not specified by user. for backwards compatibility, this is 0 (Player) /// by default. /// - [System.ComponentModel.DefaultValue(0)] - [JsonProperty(DefaultValueHandling = DefaultValueHandling.Populate)] - public uint DefaultAccessLevel { get; set; } + public uint DefaultAccessLevel { get; set; } = 0; /// /// whether or not this server creates new accounts when one does not exist. for backwards compatibility, this is true /// by default. /// - [System.ComponentModel.DefaultValue(true)] - [JsonProperty(DefaultValueHandling = DefaultValueHandling.Populate)] - public bool AllowAutoAccountCreation { get; set; } + public bool AllowAutoAccountCreation { get; set; } = true; /// /// Default WorkFactor for account passwords. /// 8 by default. /// - [System.ComponentModel.DefaultValue(8)] - [JsonProperty(DefaultValueHandling = DefaultValueHandling.Populate)] - public int PasswordHashWorkFactor { get; set; } + public int PasswordHashWorkFactor { get; set; } = 8; /// /// Upgrade or downgrade passwords to match PasswordHashWorkFactor specified in config /// True by default. /// - [System.ComponentModel.DefaultValue(true)] - [JsonProperty(DefaultValueHandling = DefaultValueHandling.Populate)] - public bool ForceWorkFactorMigration { get; set; } + public bool ForceWorkFactorMigration { get; set; } = true; } } diff --git a/Source/ACE.Common/ConfigManager.cs b/Source/ACE.Common/ConfigManager.cs index c0b284c021..de0630cf62 100644 --- a/Source/ACE.Common/ConfigManager.cs +++ b/Source/ACE.Common/ConfigManager.cs @@ -1,8 +1,7 @@ using System; using System.IO; - -using Newtonsoft.Json; -using DouglasCrockford.JsMin; +using System.Text.Json; +using System.Text.Json.Serialization; namespace ACE.Common { @@ -62,7 +61,7 @@ public static void Initialize(string path = @"Config.js") var fileText = File.ReadAllText(pathToUse); - Config = JsonConvert.DeserializeObject(new JsMinifier().Minify(fileText)); + Config = JsonSerializer.Deserialize(fileText, new JsonSerializerOptions { ReadCommentHandling = JsonCommentHandling.Skip, NumberHandling = JsonNumberHandling.AllowReadingFromString }); } catch (Exception exception) { diff --git a/Source/ACE.Common/DatabaseConfiguration.cs b/Source/ACE.Common/DatabaseConfiguration.cs index 390014f48c..fd436f6785 100644 --- a/Source/ACE.Common/DatabaseConfiguration.cs +++ b/Source/ACE.Common/DatabaseConfiguration.cs @@ -2,10 +2,31 @@ namespace ACE.Common { public class DatabaseConfiguration { - public MySqlConfiguration Authentication { get; set; } + public MySqlConfiguration Authentication { get; set; } = new MySqlConfiguration() + { + Host = "127.0.0.1", + Port = 3306, + Database = "ace_auth", + Username = "root", + Password = "" + }; - public MySqlConfiguration Shard { get; set; } + public MySqlConfiguration Shard { get; set; } = new MySqlConfiguration() + { + Host = "127.0.0.1", + Port = 3306, + Database = "ace_shard", + Username = "root", + Password = "" + }; - public MySqlConfiguration World { get; set; } + public MySqlConfiguration World { get; set; } = new MySqlConfiguration() + { + Host = "127.0.0.1", + Port = 3306, + Database = "ace_world", + Username = "root", + Password = "" + }; } } diff --git a/Source/ACE.Common/GameConfiguration.cs b/Source/ACE.Common/GameConfiguration.cs index bcd53ddca7..e3e0d02c87 100644 --- a/Source/ACE.Common/GameConfiguration.cs +++ b/Source/ACE.Common/GameConfiguration.cs @@ -1,53 +1,90 @@ -using Newtonsoft.Json; using System.Collections.Generic; namespace ACE.Common { public class GameConfiguration { - public string WorldName { get; set; } + public string WorldName { get; set; } = "ACEmulator"; public NetworkSettings Network { get; set; } public AccountDefaults Accounts { get; set; } - public string DatFilesDirectory { get; set; } + public string DatFilesDirectory { get; set; } = "c:\\ACE\\Dats\\"; /// /// The amount of seconds to wait before turning off the server. Default value is 60 (for 1 minute). /// - [System.ComponentModel.DefaultValue(60)] - [JsonProperty(DefaultValueHandling = DefaultValueHandling.Populate)] - public uint ShutdownInterval { get; set; } + public uint ShutdownInterval { get; set; } = 60; - [System.ComponentModel.DefaultValue(false)] - [JsonProperty(DefaultValueHandling = DefaultValueHandling.Populate)] - public bool ServerPerformanceMonitorAutoStart { get; set; } + public bool ServerPerformanceMonitorAutoStart { get; set; } = false; public ThreadConfiguration Threading { get; set; } = new ThreadConfiguration(); /// /// The amount of minutes to keep a player object from shard database in memory. Default value is 31 minutes. /// - [System.ComponentModel.DefaultValue(31)] - [JsonProperty(DefaultValueHandling = DefaultValueHandling.Populate)] - public uint ShardPlayerBiotaCacheTime { get; set; } + public uint ShardPlayerBiotaCacheTime { get; set; } = 31; /// /// The amount of minutes to keep a non player object from shard database in memory. Default value is 11 minutes. /// - [System.ComponentModel.DefaultValue(11)] - [JsonProperty(DefaultValueHandling = DefaultValueHandling.Populate)] - public uint ShardNonPlayerBiotaCacheTime { get; set; } + public uint ShardNonPlayerBiotaCacheTime { get; set; } = 11; - [System.ComponentModel.DefaultValue(false)] - [JsonProperty(DefaultValueHandling = DefaultValueHandling.Populate)] - public bool WorldDatabasePrecaching { get; set; } + public bool WorldDatabasePrecaching { get; set; } = false; - [System.ComponentModel.DefaultValue(true)] - [JsonProperty(DefaultValueHandling = DefaultValueHandling.Populate)] - public bool LandblockPreloading { get; set; } + public bool LandblockPreloading { get; set; } = true; - public List PreloadedLandblocks { get; set; } + public List PreloadedLandblocks { get; set; } = new List() + { + new PreloadedLandblocks() + { + Id = "E74EFFFF", + Description = "Hebian-To (Global Events)", + Permaload = true, + IncludeAdjacents = false, + Enabled = true + }, + new PreloadedLandblocks() + { + Id = "A9B4FFFF", + Description = "Holtburg", + Permaload = true, + IncludeAdjacents = true, + Enabled = false + }, + new PreloadedLandblocks() + { + Id = "DA55FFFF", + Description = "Shoushi", + Permaload = true, + IncludeAdjacents = true, + Enabled = false + }, + new PreloadedLandblocks() + { + Id = "7D64FFFF", + Description = "Yaraq", + Permaload = true, + IncludeAdjacents = true, + Enabled = false + }, + new PreloadedLandblocks() + { + Id = "0007FFFF", + Description = "Town Network", + Permaload = true, + IncludeAdjacents = false, + Enabled = false + }, + new PreloadedLandblocks() + { + Id = "00000000", + Description = "Apartment Landblocks", + Permaload = true, + IncludeAdjacents = false, + Enabled = false + } + }; } } diff --git a/Source/ACE.Common/MySqlConfiguration.cs b/Source/ACE.Common/MySqlConfiguration.cs index 71c3c73895..ce5e9b5352 100644 --- a/Source/ACE.Common/MySqlConfiguration.cs +++ b/Source/ACE.Common/MySqlConfiguration.cs @@ -2,14 +2,14 @@ namespace ACE.Common { public class MySqlConfiguration { - public string Host { get; set; } + public string Host { get; set; } = "127.0.0.1"; - public uint Port { get; set; } + public uint Port { get; set; } = 3306; - public string Database { get; set; } + public string Database { get; set; } = ""; - public string Username { get; set; } + public string Username { get; set; } = ""; - public string Password { get; set; } + public string Password { get; set; } = ""; } } diff --git a/Source/ACE.Common/NetworkSettings.cs b/Source/ACE.Common/NetworkSettings.cs index 8fb19d3abc..118d9f6ec7 100644 --- a/Source/ACE.Common/NetworkSettings.cs +++ b/Source/ACE.Common/NetworkSettings.cs @@ -1,13 +1,11 @@ -using Newtonsoft.Json; -using System.Collections.Generic; namespace ACE.Common { public class NetworkSettings { - public string Host { get; set; } + public string Host { get; set; } = "127.0.0.1"; - public uint Port { get; set; } + public uint Port { get; set; } = 9000; /// /// Increasing this setting will allow more Accounts to connect with this server. @@ -15,33 +13,25 @@ public class NetworkSettings /// /// WARNING: Must be greater then 0 to allow users to connect. /// - [System.ComponentModel.DefaultValue(128)] - [JsonProperty(DefaultValueHandling = DefaultValueHandling.Populate)] - public uint MaximumAllowedSessions { get; set; } + public uint MaximumAllowedSessions { get; set; } = 128; /// /// The amount of seconds until an active session will be declared dead/inactive. Default value is 60 (for 1 minute). /// - [System.ComponentModel.DefaultValue(60)] - [JsonProperty(DefaultValueHandling = DefaultValueHandling.Populate)] - public uint DefaultSessionTimeout { get; set; } + public uint DefaultSessionTimeout { get; set; } = 60; /// /// This setting will allow or restrict sessions based on the IPAddress connecting to the server. /// /// /// - [System.ComponentModel.DefaultValue(-1)] - [JsonProperty(DefaultValueHandling = DefaultValueHandling.Populate)] - public int MaximumAllowedSessionsPerIPAddress { get; set; } + public int MaximumAllowedSessionsPerIPAddress { get; set; } = -1; /// /// Will allow the given IP addresses to have unlimited sessions - recommend only use this for Admins /// /// /// - [System.ComponentModel.DefaultValue(new string[] { })] - [JsonProperty(DefaultValueHandling = DefaultValueHandling.Populate)] - public string[] AllowUnlimitedSessionsFromIPAddresses { get; set; } + public string[] AllowUnlimitedSessionsFromIPAddresses { get; set; } = { }; } } diff --git a/Source/ACE.Common/OfflineConfiguration.cs b/Source/ACE.Common/OfflineConfiguration.cs index b4e7bdecd9..ef4d4c4df2 100644 --- a/Source/ACE.Common/OfflineConfiguration.cs +++ b/Source/ACE.Common/OfflineConfiguration.cs @@ -1,7 +1,3 @@ -using System; - -using System.Collections.Generic; -using Newtonsoft.Json; namespace ACE.Common { @@ -15,15 +11,11 @@ public class OfflineConfiguration /// Purge characters that have been deleted longer than PruneDeletedCharactersDays /// These characters, and their associated biotas, will be deleted permanantly! /// - [System.ComponentModel.DefaultValue(false)] - [JsonProperty(DefaultValueHandling = DefaultValueHandling.Populate)] - public bool PurgeDeletedCharacters { get; set; } + public bool PurgeDeletedCharacters { get; set; } = false; /// /// Number of days a character must have been deleted for before eligible for purging /// - [System.ComponentModel.DefaultValue(30)] - [JsonProperty(DefaultValueHandling = DefaultValueHandling.Populate)] public int PurgeDeletedCharactersDays { get; set; } = 30; /// @@ -31,53 +23,39 @@ public class OfflineConfiguration /// These may have been items that were never deleted properly, items that were given to the town crier before delete was implemented, etc... /// This can be time consuming so it's not something you would have set to true for every server startup. You might run this once every few months /// - [System.ComponentModel.DefaultValue(false)] - [JsonProperty(DefaultValueHandling = DefaultValueHandling.Populate)] - public bool PurgeOrphanedBiotas { get; set; } + public bool PurgeOrphanedBiotas { get; set; } = false; /// /// Prune deleted characters from all friend lists /// - [System.ComponentModel.DefaultValue(true)] - [JsonProperty(DefaultValueHandling = DefaultValueHandling.Populate)] - public bool PruneDeletedCharactersFromFriendLists { get; set; } + public bool PruneDeletedCharactersFromFriendLists { get; set; } = true; /// /// Prune deleted objects from all shortcut bars /// - [System.ComponentModel.DefaultValue(false)] - [JsonProperty(DefaultValueHandling = DefaultValueHandling.Populate)] - public bool PruneDeletedObjectsFromShortcutBars { get; set; } + public bool PruneDeletedObjectsFromShortcutBars { get; set; } = false; /// /// Prune deleted characters from all squelch lists, excluding those used to squelch entire accounts /// - [System.ComponentModel.DefaultValue(false)] - [JsonProperty(DefaultValueHandling = DefaultValueHandling.Populate)] - public bool PruneDeletedCharactersFromSquelchLists { get; set; } + public bool PruneDeletedCharactersFromSquelchLists { get; set; } = false; /// /// Automatically check for and update to latest available world database /// - [System.ComponentModel.DefaultValue(false)] - [JsonProperty(DefaultValueHandling = DefaultValueHandling.Populate)] - public bool AutoUpdateWorldDatabase { get; set; } + public bool AutoUpdateWorldDatabase { get; set; } = false; /// /// Automatically check for updated server binaries /// - [System.ComponentModel.DefaultValue(true)] - [JsonProperty(DefaultValueHandling = DefaultValueHandling.Populate)] - public bool AutoServerUpdateCheck { get; set; } + public bool AutoServerUpdateCheck { get; set; } = true; /// /// After updating to latest world database, automatically import further customizations /// AutoUpdateWorldDatabase must be true for this option to be used /// SQL files will be executed given the sort order of the full paths of the files /// - [System.ComponentModel.DefaultValue(false)] - [JsonProperty(DefaultValueHandling = DefaultValueHandling.Populate)] - public bool AutoApplyWorldCustomizations { get; set; } + public bool AutoApplyWorldCustomizations { get; set; } = false; /// /// When AutoApplyWorldCustomizations is set to true, the auto apply process will search for @@ -85,23 +63,17 @@ public class OfflineConfiguration /// This process will still use ./Content by default, or the the config_properties_string /// value for 'content_folder' if it exists /// - [System.ComponentModel.DefaultValue(new string[] { })] - [JsonProperty(DefaultValueHandling = DefaultValueHandling.Populate)] - public string[] WorldCustomizationAddedPaths { get; set; } + public string[] WorldCustomizationAddedPaths { get; set; } = { }; /// /// When retrieving a file list of .sql files in the AutoApplyWorldCustomizations process /// this will cause the file search to retrieve all files recursively from each directory /// - [System.ComponentModel.DefaultValue(false)] - [JsonProperty(DefaultValueHandling = DefaultValueHandling.Populate)] - public bool RecurseWorldCustomizationPaths { get; set; } + public bool RecurseWorldCustomizationPaths { get; set; } = false; /// /// Automatically apply new updates to databases upon startup if they haven't yet been applied /// - [System.ComponentModel.DefaultValue(false)] - [JsonProperty(DefaultValueHandling = DefaultValueHandling.Populate)] - public bool AutoApplyDatabaseUpdates { get; set; } + public bool AutoApplyDatabaseUpdates { get; set; } = false; } } diff --git a/Source/ACE.Common/PreloadedLandblock.cs b/Source/ACE.Common/PreloadedLandblock.cs index 69984342bb..b927a5c234 100644 --- a/Source/ACE.Common/PreloadedLandblock.cs +++ b/Source/ACE.Common/PreloadedLandblock.cs @@ -1,4 +1,3 @@ -using Newtonsoft.Json; namespace ACE.Common { @@ -17,22 +16,16 @@ public class PreloadedLandblocks /// /// whether or not this landblock is permaloaded /// - [System.ComponentModel.DefaultValue(false)] - [JsonProperty(DefaultValueHandling = DefaultValueHandling.Populate)] - public bool Permaload { get; set; } + public bool Permaload { get; set; } = false; /// /// whether or not this landblock should also load adjacents, if Permaload is true, the ajacent landblocks will also be marked permaload /// - [System.ComponentModel.DefaultValue(false)] - [JsonProperty(DefaultValueHandling = DefaultValueHandling.Populate)] - public bool IncludeAdjacents { get; set; } + public bool IncludeAdjacents { get; set; } = false; /// /// whether or not this landblock is included for preload. /// - [System.ComponentModel.DefaultValue(false)] - [JsonProperty(DefaultValueHandling = DefaultValueHandling.Populate)] - public bool Enabled { get; set; } + public bool Enabled { get; set; } = false; } } diff --git a/Source/ACE.Common/ThreadConfiguration.cs b/Source/ACE.Common/ThreadConfiguration.cs index df9c5e1223..b1bbc92de8 100644 --- a/Source/ACE.Common/ThreadConfiguration.cs +++ b/Source/ACE.Common/ThreadConfiguration.cs @@ -1,8 +1,7 @@ using System; +using System.Text.Json.Serialization; using System.Threading.Tasks; -using Newtonsoft.Json; - namespace ACE.Common { /// @@ -11,8 +10,8 @@ namespace ACE.Common /// public class ThreadConfiguration { - private double worldThreadCountMultiplier; - private double databaseThreadCountMultiplier; + private double worldThreadCountMultiplier = 0.34; + private double databaseThreadCountMultiplier = 0; /* * Multiplier of 0.34: @@ -30,8 +29,6 @@ public class ThreadConfiguration * 12 vCPU = 4 thread world, 8 thread database */ - [System.ComponentModel.DefaultValue(0.34)] - [JsonProperty(DefaultValueHandling = DefaultValueHandling.Populate)] public double WorldThreadCountMultiplier { get => worldThreadCountMultiplier; @@ -46,8 +43,6 @@ public double WorldThreadCountMultiplier } } - [System.ComponentModel.DefaultValue(0)] - [JsonProperty(DefaultValueHandling = DefaultValueHandling.Populate)] public double DatabaseThreadCountMultiplier { get => databaseThreadCountMultiplier; @@ -70,13 +65,9 @@ public double DatabaseThreadCountMultiplier } } - [System.ComponentModel.DefaultValue(false)] - [JsonProperty(DefaultValueHandling = DefaultValueHandling.Populate)] - public bool MultiThreadedLandblockGroupPhysicsTicking { get; set; } + public bool MultiThreadedLandblockGroupPhysicsTicking { get; set; } = false; - [System.ComponentModel.DefaultValue(false)] - [JsonProperty(DefaultValueHandling = DefaultValueHandling.Populate)] - public bool MultiThreadedLandblockGroupTicking { get; set; } + public bool MultiThreadedLandblockGroupTicking { get; set; } = false; // World Thread Management diff --git a/Source/ACE.Server.Tests/ACE.Server.Tests.csproj b/Source/ACE.Server.Tests/ACE.Server.Tests.csproj index ae76c8cc40..9db3190622 100644 --- a/Source/ACE.Server.Tests/ACE.Server.Tests.csproj +++ b/Source/ACE.Server.Tests/ACE.Server.Tests.csproj @@ -31,7 +31,6 @@ - diff --git a/Source/ACE.Server/ACE.Server.csproj b/Source/ACE.Server/ACE.Server.csproj index d1cbfb461d..008585d525 100644 --- a/Source/ACE.Server/ACE.Server.csproj +++ b/Source/ACE.Server/ACE.Server.csproj @@ -237,7 +237,6 @@ - diff --git a/Source/ACE.Server/Command/Handlers/DeveloperContentCommands.cs b/Source/ACE.Server/Command/Handlers/DeveloperContentCommands.cs index 1e35d6f755..48ae2f01d8 100644 --- a/Source/ACE.Server/Command/Handlers/DeveloperContentCommands.cs +++ b/Source/ACE.Server/Command/Handlers/DeveloperContentCommands.cs @@ -4,10 +4,10 @@ using System.IO; using System.Linq; using System.Numerics; +using System.Text.Json; using System.Text.RegularExpressions; using Microsoft.EntityFrameworkCore; -using Newtonsoft.Json; using ACE.Adapter.GDLE; using ACE.Adapter.Lifestoned; @@ -581,7 +581,7 @@ public static string json2sql_weenie(Session session, string folder, string json var metadata = new Adapter.GDLE.Models.Metadata(weenie); if (metadata.HasInfo) { - var jsonEx = JsonConvert.SerializeObject(metadata, LifestonedConverter.SerializerSettings); + var jsonEx = JsonSerializer.Serialize(metadata, LifestonedConverter.SerializerSettings); sqlFile.WriteLine($"\n/* Lifestoned Changelog:\n{jsonEx}\n*/"); } @@ -988,7 +988,7 @@ public static bool sql2json_weenie(Session session, Weenie weenie, string sql_fo if (File.Exists(json_folder + json_filename) && LifestonedLoader.AppendMetadata(json_folder + json_filename, json_weenie)) { - json = JsonConvert.SerializeObject(json_weenie, LifestonedConverter.SerializerSettings); + json = JsonSerializer.Serialize(json_weenie, LifestonedConverter.SerializerSettings); } File.WriteAllText(json_folder + json_filename, json); @@ -1022,7 +1022,7 @@ public static bool sql2json_recipe(Session session, List cookbooks, st if (!di.Exists) di.Create(); - var json = JsonConvert.SerializeObject(result, LifestonedConverter.SerializerSettings); + var json = JsonSerializer.Serialize(result, LifestonedConverter.SerializerSettings); File.WriteAllText(json_folder + json_filename, json); @@ -1053,7 +1053,7 @@ public static bool sql2json_landblock(Session session, List i if (!di.Exists) di.Create(); - var json = JsonConvert.SerializeObject(result, LifestonedConverter.SerializerSettings); + var json = JsonSerializer.Serialize(result, LifestonedConverter.SerializerSettings); File.WriteAllText(json_folder + json_filename, json); @@ -1078,7 +1078,7 @@ public static bool sql2json_quest(Session session, Quest quest, string sql_folde if (!di.Exists) di.Create(); - var json = JsonConvert.SerializeObject(result, LifestonedConverter.SerializerSettings); + var json = JsonSerializer.Serialize(result, LifestonedConverter.SerializerSettings); File.WriteAllText(json_folder + json_filename, json); @@ -1897,7 +1897,7 @@ public static void ExportJsonWeenie(Session session, string param, bool withFold if (File.Exists(json_folder + json_filename) && LifestonedLoader.AppendMetadata(json_folder + json_filename, json_weenie)) { - json = JsonConvert.SerializeObject(json_weenie, LifestonedConverter.SerializerSettings); + json = JsonSerializer.Serialize(json_weenie, LifestonedConverter.SerializerSettings); } File.WriteAllText(json_folder + json_filename, json); @@ -1947,7 +1947,7 @@ public static void ExportJsonRecipe(Session session, string param) var json_filename = $"{recipeId.ToString("00000")} - {desc}.json"; - var json = JsonConvert.SerializeObject(result, LifestonedConverter.SerializerSettings); + var json = JsonSerializer.Serialize(result, LifestonedConverter.SerializerSettings); File.WriteAllText(json_folder + json_filename, json); @@ -1994,7 +1994,7 @@ public static void ExportJsonLandblock(Session session, string param) var json_filename = $"{landblockId:X4}.json"; - var json = JsonConvert.SerializeObject(result, LifestonedConverter.SerializerSettings); + var json = JsonSerializer.Serialize(result, LifestonedConverter.SerializerSettings); File.WriteAllText(json_folder + json_filename, json); @@ -2030,7 +2030,7 @@ public static void ExportJsonQuest(Session session, string questName) var json_filename = $"{questName}.json"; - var json = JsonConvert.SerializeObject(result, LifestonedConverter.SerializerSettings); + var json = JsonSerializer.Serialize(result, LifestonedConverter.SerializerSettings); File.WriteAllText(json_folder + json_filename, json); diff --git a/Source/ACE.Server/Entity/StarterGearConfiguration.cs b/Source/ACE.Server/Entity/StarterGearConfiguration.cs index 39cce918f8..24c3be6084 100644 --- a/Source/ACE.Server/Entity/StarterGearConfiguration.cs +++ b/Source/ACE.Server/Entity/StarterGearConfiguration.cs @@ -1,11 +1,11 @@ -using System.Collections.Generic; -using Newtonsoft.Json; +using System.Collections.Generic; +using System.Text.Json.Serialization; namespace ACE.Server.Entity { public class StarterGearConfiguration { - [JsonProperty("skills")] + [JsonPropertyName("skills")] public List Skills { get; set; } } } diff --git a/Source/ACE.Server/Entity/StarterGearSkill.cs b/Source/ACE.Server/Entity/StarterGearSkill.cs index 9d33d0fd63..28b3f88e0b 100644 --- a/Source/ACE.Server/Entity/StarterGearSkill.cs +++ b/Source/ACE.Server/Entity/StarterGearSkill.cs @@ -1,26 +1,26 @@ -using System.Collections.Generic; -using Newtonsoft.Json; +using System.Collections.Generic; +using System.Text.Json.Serialization; namespace ACE.Server.Entity { public class StarterGearSkill { - [JsonProperty("id")] + [JsonPropertyName("id")] public ushort SkillId { get; set; } /// /// not used, but the file has it for readability /// - [JsonProperty("name")] + [JsonPropertyName("name")] public string Name { get; set; } - [JsonProperty("gear")] + [JsonPropertyName("gear")] public List Gear { get; set; } = new List(); - [JsonProperty("heritage")] + [JsonPropertyName("heritage")] public List Heritage { get; set; } = new List(); - [JsonProperty("spells")] + [JsonPropertyName("spells")] public List Spells { get; set; } = new List(); } } diff --git a/Source/ACE.Server/Entity/StarterHeritage.cs b/Source/ACE.Server/Entity/StarterHeritage.cs index de4e6c94ac..55fd6b66c3 100644 --- a/Source/ACE.Server/Entity/StarterHeritage.cs +++ b/Source/ACE.Server/Entity/StarterHeritage.cs @@ -1,26 +1,26 @@ using System.Collections.Generic; -using Newtonsoft.Json; +using System.Text.Json.Serialization; namespace ACE.Server.Entity { public class StarterHeritage { - [JsonProperty("id")] + [JsonPropertyName("id")] public ushort HeritageId { get; set; } /// /// not used, but the file has it for readability /// - [JsonProperty("name")] + [JsonPropertyName("name")] public string Name { get; set; } - [JsonProperty("gear")] + [JsonPropertyName("gear")] public List Gear { get; set; } = new List(); /// /// Only needed to give an Olthoi Spitter starter spells. /// - [JsonProperty("spells")] + [JsonPropertyName("spells")] public List Spells { get; set; } = new List(); } } diff --git a/Source/ACE.Server/Entity/StarterItem.cs b/Source/ACE.Server/Entity/StarterItem.cs index c7c2950986..2fb94ea4ff 100644 --- a/Source/ACE.Server/Entity/StarterItem.cs +++ b/Source/ACE.Server/Entity/StarterItem.cs @@ -1,4 +1,4 @@ -using Newtonsoft.Json; +using System.Text.Json.Serialization; namespace ACE.Server.Entity { @@ -9,10 +9,10 @@ public StarterItem() StackSize = 1; } - [JsonProperty("weenieId")] + [JsonPropertyName("weenieId")] public uint WeenieId { get; set; } - [JsonProperty("stacksize")] + [JsonPropertyName("stacksize")] public ushort StackSize { get; set; } } } diff --git a/Source/ACE.Server/Entity/StarterSpell.cs b/Source/ACE.Server/Entity/StarterSpell.cs index ce724f84c3..df1017d154 100644 --- a/Source/ACE.Server/Entity/StarterSpell.cs +++ b/Source/ACE.Server/Entity/StarterSpell.cs @@ -1,19 +1,20 @@ -using Newtonsoft.Json; +using System.Text.Json.Serialization; +using static ACE.Server.Factories.StarterGearFactory; namespace ACE.Server.Entity { public class StarterSpell { - [JsonProperty("spellId")] + [JsonPropertyName("spellId")] public uint SpellId { get; set; } /// /// not used, but in the json file for readability /// - [JsonProperty("name")] + [JsonPropertyName("name")] public string Name { get; set; } - [JsonProperty("specializedOnly")] + [JsonPropertyName("specializedOnly"), JsonConverter(typeof(StringToBoolConverter))] public bool SpecializedOnly { get; set; } } } diff --git a/Source/ACE.Server/Factories/StarterGearFactory.cs b/Source/ACE.Server/Factories/StarterGearFactory.cs index 79b1a33a11..15d0559920 100644 --- a/Source/ACE.Server/Factories/StarterGearFactory.cs +++ b/Source/ACE.Server/Factories/StarterGearFactory.cs @@ -1,11 +1,12 @@ using System; using System.IO; using System.Reflection; +using System.Text.Json; +using System.Text.Json.Serialization; using ACE.Server.Entity; using log4net; -using Newtonsoft.Json; namespace ACE.Server.Factories { @@ -35,7 +36,7 @@ private static StarterGearConfiguration LoadConfigFromResource() { var starterGearText = File.ReadAllText(starterGearFile); - config = JsonConvert.DeserializeObject(starterGearText); + config = JsonSerializer.Deserialize(starterGearText, new JsonSerializerOptions { ReadCommentHandling = JsonCommentHandling.Skip, NumberHandling = JsonNumberHandling.AllowReadingFromString, }); return config; } @@ -58,5 +59,35 @@ public static StarterGearConfiguration GetStarterGearConfiguration() return null; } } + + public class StringToBoolConverter : JsonConverter + { + public override bool Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) + { + + if (reader.TokenType == JsonTokenType.String) + { + var boolString = reader.GetString(); + + return Convert.ToBoolean(boolString); + } + else if (reader.TokenType == JsonTokenType.True) + { + return true; + } + else if (reader.TokenType == JsonTokenType.False) + { + return false; + } + + throw new JsonException(); + } + + public override void Write(Utf8JsonWriter writer, bool value, JsonSerializerOptions options) + { + writer.WriteBooleanValue(value); + } + + } } } diff --git a/Source/ACE.Server/Managers/RecipeManager_New.cs b/Source/ACE.Server/Managers/RecipeManager_New.cs index 827d39cd61..e3796e9aae 100644 --- a/Source/ACE.Server/Managers/RecipeManager_New.cs +++ b/Source/ACE.Server/Managers/RecipeManager_New.cs @@ -1,7 +1,6 @@ using System.Collections.Generic; using System.IO; - -using Newtonsoft.Json; +using System.Text.Json; using ACE.Database; using ACE.Database.Models.World; @@ -21,7 +20,7 @@ public static void ReadJSON() // read recipeprecursors.json // tool -> target -> recipe var json = File.ReadAllText(@"json\recipeprecursors.json"); - var precursors = JsonConvert.DeserializeObject>(json); + var precursors = JsonSerializer.Deserialize>(json); Precursors = new Dictionary>(); foreach (var precursor in precursors) diff --git a/Source/ACE.Server/Program_BinUpdates.cs b/Source/ACE.Server/Program_BinUpdates.cs index 5b4cd7b40f..857f01ecbe 100644 --- a/Source/ACE.Server/Program_BinUpdates.cs +++ b/Source/ACE.Server/Program_BinUpdates.cs @@ -1,16 +1,5 @@ -extern alias MySqlConnectorAlias; - using System; -using System.IO; -using System.IO.Compression; -using System.Linq; -using System.Net; -using System.Threading; -using System.Collections.Generic; - -using ACE.Common; - -using Newtonsoft.Json; +using System.Text.Json; namespace ACE.Server { @@ -29,9 +18,9 @@ private static void CheckForServerUpdate() using var client = new WebClient(); var html = client.GetStringFromURL(url).Result; - dynamic json = JsonConvert.DeserializeObject(html); + var json = JsonSerializer.Deserialize(html); - string tag = json.tag_name; + string tag = json.GetProperty("tag_name").GetString(); //Split the tag from "v{version}.{build}" into discrete components - "tag_name": "v1.39.4192" Version v = new Version(tag.Remove(0, 1)); @@ -42,7 +31,7 @@ private static void CheckForServerUpdate() if (versionStatus > 0) { log.Warn("There is a newer version of ACE available!"); - log.Warn($"Please visit {json.html_url} for more information."); + log.Warn($"Please visit {json.GetProperty("html_url").GetString()} for more information."); // the Console.Title.Get() only works on Windows... #pragma warning disable CA1416 // Validate platform compatibility diff --git a/Source/ACE.Server/Program_DbUpdates.cs b/Source/ACE.Server/Program_DbUpdates.cs index b24aa91cc1..d3c63a25ca 100644 --- a/Source/ACE.Server/Program_DbUpdates.cs +++ b/Source/ACE.Server/Program_DbUpdates.cs @@ -1,16 +1,15 @@ extern alias MySqlConnectorAlias; using System; +using System.Collections.Generic; using System.IO; using System.IO.Compression; using System.Linq; +using System.Text.Json; using System.Threading; -using System.Collections.Generic; using ACE.Common; -using Newtonsoft.Json; - namespace ACE.Server { partial class Program @@ -28,10 +27,10 @@ private static void CheckForWorldDatabaseUpdate() using var client = new WebClient(); var html = client.GetStringFromURL(url).Result; - dynamic json = JsonConvert.DeserializeObject(html); - string tag = json.tag_name; - string dbURL = json.assets[0].browser_download_url; - string dbFileName = json.assets[0].name; + var json = JsonSerializer.Deserialize(html); + string tag = json.GetProperty("tag_name").GetString(); + string dbURL = json.GetProperty("assets")[0].GetProperty("browser_download_url").GetString(); + string dbFileName = json.GetProperty("assets")[0].GetProperty("name").GetString(); if (currentVersion.PatchVersion != tag) { diff --git a/Source/ACE.Server/Program_Setup.cs b/Source/ACE.Server/Program_Setup.cs index f67cac9aaf..a0ee98fe8c 100644 --- a/Source/ACE.Server/Program_Setup.cs +++ b/Source/ACE.Server/Program_Setup.cs @@ -4,11 +4,10 @@ using System.IO; using System.IO.Compression; using System.Linq; +using System.Text.Json; using System.Threading; -using ACE.Common; -using DouglasCrockford.JsMin; -using Newtonsoft.Json; +using ACE.Common; namespace ACE.Server { @@ -40,7 +39,7 @@ private static void DoOutOfBoxSetup(string configFile) } var fileText = File.ReadAllText(configFile); - var config = JsonConvert.DeserializeObject(new JsMinifier().Minify(fileText)); + var config = JsonSerializer.Deserialize(fileText); Console.WriteLine("Performing setup for ACEmulator..."); Console.WriteLine(); @@ -260,14 +259,17 @@ private static void DoOutOfBoxSetup(string configFile) } Console.WriteLine("commiting configuration to memory..."); - using (StreamWriter file = File.CreateText(configFile)) - { - JsonSerializer serializer = new JsonSerializer(); - serializer.Formatting = Formatting.Indented; - //serializer.NullValueHandling = NullValueHandling.Ignore; - //serializer.DefaultValueHandling = DefaultValueHandling.Ignore; - serializer.Serialize(file, config); - } + //using (StreamWriter file = File.CreateText(configFile)) + //{ + // JsonSerializer serializer = new JsonSerializer(); + // serializer.Formatting = Formatting.Indented; + // //serializer.NullValueHandling = NullValueHandling.Ignore; + // //serializer.DefaultValueHandling = DefaultValueHandling.Ignore; + // serializer.Serialize(file, config); + //} + + var jsonString = JsonSerializer.Serialize(config, new JsonSerializerOptions { WriteIndented = true }); + File.WriteAllText(configFile, jsonString); Console.WriteLine(); @@ -395,7 +397,7 @@ private static void DoOutOfBoxSetup(string configFile) using var client = new WebClient(); var html = client.GetStringFromURL(url).Result; - dynamic json = JsonConvert.DeserializeObject(html); + dynamic json = JsonSerializer.Deserialize(html); string tag = json.tag_name; string dbURL = json.assets[0].browser_download_url; string dbFileName = json.assets[0].name; From eea9b003921fc0fa00505abe9a6587e727ef8f91 Mon Sep 17 00:00:00 2001 From: Ty Conner Date: Thu, 4 May 2023 19:34:51 -0400 Subject: [PATCH 02/22] Update GameConfiguration.cs --- Source/ACE.Common/GameConfiguration.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Source/ACE.Common/GameConfiguration.cs b/Source/ACE.Common/GameConfiguration.cs index e3e0d02c87..580680a6a4 100644 --- a/Source/ACE.Common/GameConfiguration.cs +++ b/Source/ACE.Common/GameConfiguration.cs @@ -6,9 +6,9 @@ public class GameConfiguration { public string WorldName { get; set; } = "ACEmulator"; - public NetworkSettings Network { get; set; } + public NetworkSettings Network { get; set; } = new NetworkSettings(); - public AccountDefaults Accounts { get; set; } + public AccountDefaults Accounts { get; set; } = new AccountDefaults(); public string DatFilesDirectory { get; set; } = "c:\\ACE\\Dats\\"; From 39909035162d7f14a6256eb2d88a78fd1b2f3247 Mon Sep 17 00:00:00 2001 From: Ty Conner Date: Thu, 4 May 2023 19:34:54 -0400 Subject: [PATCH 03/22] Update MasterConfiguration.cs --- Source/ACE.Common/MasterConfiguration.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Source/ACE.Common/MasterConfiguration.cs b/Source/ACE.Common/MasterConfiguration.cs index f66b90ff50..5a8d1f307c 100644 --- a/Source/ACE.Common/MasterConfiguration.cs +++ b/Source/ACE.Common/MasterConfiguration.cs @@ -2,9 +2,9 @@ namespace ACE.Common { public class MasterConfiguration { - public GameConfiguration Server { get; set; } + public GameConfiguration Server { get; set; } = new GameConfiguration(); - public DatabaseConfiguration MySql { get; set; } + public DatabaseConfiguration MySql { get; set; } = new DatabaseConfiguration(); public OfflineConfiguration Offline { get; set; } = new OfflineConfiguration(); } From a67b8ce0cf207dd6a4f726dd6345499519e4a352 Mon Sep 17 00:00:00 2001 From: Ty Conner Date: Thu, 4 May 2023 19:34:56 -0400 Subject: [PATCH 04/22] Update ThreadConfiguration.cs --- Source/ACE.Common/ThreadConfiguration.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Source/ACE.Common/ThreadConfiguration.cs b/Source/ACE.Common/ThreadConfiguration.cs index b1bbc92de8..66c739ff18 100644 --- a/Source/ACE.Common/ThreadConfiguration.cs +++ b/Source/ACE.Common/ThreadConfiguration.cs @@ -11,7 +11,7 @@ namespace ACE.Common public class ThreadConfiguration { private double worldThreadCountMultiplier = 0.34; - private double databaseThreadCountMultiplier = 0; + private double databaseThreadCountMultiplier = 0.66; /* * Multiplier of 0.34: From 83754f25a43145466a42af9dd245eeed313a66b4 Mon Sep 17 00:00:00 2001 From: Ty Conner Date: Thu, 4 May 2023 19:35:19 -0400 Subject: [PATCH 05/22] Update StarterSpell.cs --- Source/ACE.Server/Entity/StarterSpell.cs | 32 +++++++++++++++++++++++- 1 file changed, 31 insertions(+), 1 deletion(-) diff --git a/Source/ACE.Server/Entity/StarterSpell.cs b/Source/ACE.Server/Entity/StarterSpell.cs index df1017d154..e791552732 100644 --- a/Source/ACE.Server/Entity/StarterSpell.cs +++ b/Source/ACE.Server/Entity/StarterSpell.cs @@ -1,5 +1,6 @@ +using System; +using System.Text.Json; using System.Text.Json.Serialization; -using static ACE.Server.Factories.StarterGearFactory; namespace ACE.Server.Entity { @@ -17,4 +18,33 @@ public class StarterSpell [JsonPropertyName("specializedOnly"), JsonConverter(typeof(StringToBoolConverter))] public bool SpecializedOnly { get; set; } } + + public class StringToBoolConverter : JsonConverter + { + public override bool Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) + { + if (reader.TokenType == JsonTokenType.String) + { + var boolString = reader.GetString(); + + return Convert.ToBoolean(boolString); + } + else if (reader.TokenType == JsonTokenType.True) + { + return true; + } + else if (reader.TokenType == JsonTokenType.False) + { + return false; + } + + throw new JsonException(); + } + + public override void Write(Utf8JsonWriter writer, bool value, JsonSerializerOptions options) + { + writer.WriteBooleanValue(value); + } + + } } From 6f66ca0bff0ed0084efbfcb3d524e203d35c4dda Mon Sep 17 00:00:00 2001 From: Ty Conner Date: Thu, 4 May 2023 19:35:22 -0400 Subject: [PATCH 06/22] Update StarterGearFactory.cs --- .../Factories/StarterGearFactory.cs | 30 ------------------- 1 file changed, 30 deletions(-) diff --git a/Source/ACE.Server/Factories/StarterGearFactory.cs b/Source/ACE.Server/Factories/StarterGearFactory.cs index 15d0559920..46aab6c468 100644 --- a/Source/ACE.Server/Factories/StarterGearFactory.cs +++ b/Source/ACE.Server/Factories/StarterGearFactory.cs @@ -59,35 +59,5 @@ public static StarterGearConfiguration GetStarterGearConfiguration() return null; } } - - public class StringToBoolConverter : JsonConverter - { - public override bool Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) - { - - if (reader.TokenType == JsonTokenType.String) - { - var boolString = reader.GetString(); - - return Convert.ToBoolean(boolString); - } - else if (reader.TokenType == JsonTokenType.True) - { - return true; - } - else if (reader.TokenType == JsonTokenType.False) - { - return false; - } - - throw new JsonException(); - } - - public override void Write(Utf8JsonWriter writer, bool value, JsonSerializerOptions options) - { - writer.WriteBooleanValue(value); - } - - } } } From 207f1ec22755bbb1462c46d4e875178fd0bff1fd Mon Sep 17 00:00:00 2001 From: Ty Conner Date: Thu, 4 May 2023 19:35:39 -0400 Subject: [PATCH 07/22] Update Program_Setup.cs --- Source/ACE.Server/Program_Setup.cs | 60 +++++++++++++++--------------- 1 file changed, 31 insertions(+), 29 deletions(-) diff --git a/Source/ACE.Server/Program_Setup.cs b/Source/ACE.Server/Program_Setup.cs index a0ee98fe8c..ca4b3e91db 100644 --- a/Source/ACE.Server/Program_Setup.cs +++ b/Source/ACE.Server/Program_Setup.cs @@ -15,31 +15,33 @@ partial class Program { private static void DoOutOfBoxSetup(string configFile) { - var exeLocation = Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location); - var configJsExample = Path.Combine(exeLocation, "Config.js.example"); - var exampleFile = new FileInfo(configJsExample); - if (!exampleFile.Exists) - { - log.Error("config.js.example Configuration file is missing. Please copy the file config.js.example to config.js and edit it to match your needs before running ACE."); - throw new Exception("missing config.js configuration file"); - } - else - { - if (!IsRunningInContainer) - { - Console.WriteLine("config.js Configuration file is missing, cloning from example file."); - File.Copy(configJsExample, configFile, true); - } - else - { - Console.WriteLine("config.js Configuration file is missing, ACEmulator is running in a container, cloning from docker file."); - var configJsDocker = Path.Combine(exeLocation, "Config.js.docker"); - File.Copy(configJsDocker, configFile, true); - } - } + //var exeLocation = Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location); + //var configJsExample = Path.Combine(exeLocation, "Config.js.example"); + //var exampleFile = new FileInfo(configJsExample); + //if (!exampleFile.Exists) + //{ + // log.Error("config.js.example Configuration file is missing. Please copy the file config.js.example to config.js and edit it to match your needs before running ACE."); + // throw new Exception("missing config.js configuration file"); + //} + //else + //{ + // if (!IsRunningInContainer) + // { + // Console.WriteLine("config.js Configuration file is missing, cloning from example file."); + // File.Copy(configJsExample, configFile, true); + // } + // else + // { + // Console.WriteLine("config.js Configuration file is missing, ACEmulator is running in a container, cloning from docker file."); + // var configJsDocker = Path.Combine(exeLocation, "Config.js.docker"); + // File.Copy(configJsDocker, configFile, true); + // } + //} + + //var fileText = File.ReadAllText(configFile); + //var config = JsonSerializer.Deserialize(fileText); - var fileText = File.ReadAllText(configFile); - var config = JsonSerializer.Deserialize(fileText); + var config = new MasterConfiguration(); Console.WriteLine("Performing setup for ACEmulator..."); Console.WriteLine(); @@ -258,7 +260,7 @@ private static void DoOutOfBoxSetup(string configFile) config.MySql.World.Password = variable.Trim(); } - Console.WriteLine("commiting configuration to memory..."); + Console.WriteLine("commiting configuration to disk..."); //using (StreamWriter file = File.CreateText(configFile)) //{ // JsonSerializer serializer = new JsonSerializer(); @@ -397,10 +399,10 @@ private static void DoOutOfBoxSetup(string configFile) using var client = new WebClient(); var html = client.GetStringFromURL(url).Result; - dynamic json = JsonSerializer.Deserialize(html); - string tag = json.tag_name; - string dbURL = json.assets[0].browser_download_url; - string dbFileName = json.assets[0].name; + var json = JsonSerializer.Deserialize(html); + string tag = json.GetProperty("tag_name").GetString(); + string dbURL = json.GetProperty("assets")[0].GetProperty("browser_download_url").GetString(); + string dbFileName = json.GetProperty("assets")[0].GetProperty("name").GetString(); Console.WriteLine($"Found {tag} !"); From 52e003ae55cd140d4e140255f060eaa5337a1494 Mon Sep 17 00:00:00 2001 From: Ty Conner Date: Thu, 4 May 2023 23:52:06 -0400 Subject: [PATCH 08/22] Update LifestonedConverter.cs --- Source/ACE.Adapter/Lifestoned/LifestonedConverter.cs | 6 ------ 1 file changed, 6 deletions(-) diff --git a/Source/ACE.Adapter/Lifestoned/LifestonedConverter.cs b/Source/ACE.Adapter/Lifestoned/LifestonedConverter.cs index eebf90dd11..2f74c42d88 100644 --- a/Source/ACE.Adapter/Lifestoned/LifestonedConverter.cs +++ b/Source/ACE.Adapter/Lifestoned/LifestonedConverter.cs @@ -1117,12 +1117,6 @@ public static bool TryConvertACEWeeniesToLSDJSON(List weenies, out List< static LifestonedConverter() { - ////SerializerSettings.Converters.Add(new JavaScriptDateTimeConverter()); - //SerializerSettings.NullValueHandling = NullValueHandling.Ignore; - //SerializerSettings.DateFormatHandling = DateFormatHandling.IsoDateFormat; - - //SerializerSettings.Formatting = Formatting.Indented; - SerializerSettings.WriteIndented = true; } From b12c914e1037f2b687d6150cb8a8090724e5217e Mon Sep 17 00:00:00 2001 From: Ty Conner Date: Thu, 4 May 2023 23:52:09 -0400 Subject: [PATCH 09/22] Update Program_Setup.cs --- Source/ACE.Server/Program_Setup.cs | 34 ------------------------------ 1 file changed, 34 deletions(-) diff --git a/Source/ACE.Server/Program_Setup.cs b/Source/ACE.Server/Program_Setup.cs index ca4b3e91db..986b4ed5f7 100644 --- a/Source/ACE.Server/Program_Setup.cs +++ b/Source/ACE.Server/Program_Setup.cs @@ -15,32 +15,6 @@ partial class Program { private static void DoOutOfBoxSetup(string configFile) { - //var exeLocation = Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location); - //var configJsExample = Path.Combine(exeLocation, "Config.js.example"); - //var exampleFile = new FileInfo(configJsExample); - //if (!exampleFile.Exists) - //{ - // log.Error("config.js.example Configuration file is missing. Please copy the file config.js.example to config.js and edit it to match your needs before running ACE."); - // throw new Exception("missing config.js configuration file"); - //} - //else - //{ - // if (!IsRunningInContainer) - // { - // Console.WriteLine("config.js Configuration file is missing, cloning from example file."); - // File.Copy(configJsExample, configFile, true); - // } - // else - // { - // Console.WriteLine("config.js Configuration file is missing, ACEmulator is running in a container, cloning from docker file."); - // var configJsDocker = Path.Combine(exeLocation, "Config.js.docker"); - // File.Copy(configJsDocker, configFile, true); - // } - //} - - //var fileText = File.ReadAllText(configFile); - //var config = JsonSerializer.Deserialize(fileText); - var config = new MasterConfiguration(); Console.WriteLine("Performing setup for ACEmulator..."); @@ -261,14 +235,6 @@ private static void DoOutOfBoxSetup(string configFile) } Console.WriteLine("commiting configuration to disk..."); - //using (StreamWriter file = File.CreateText(configFile)) - //{ - // JsonSerializer serializer = new JsonSerializer(); - // serializer.Formatting = Formatting.Indented; - // //serializer.NullValueHandling = NullValueHandling.Ignore; - // //serializer.DefaultValueHandling = DefaultValueHandling.Ignore; - // serializer.Serialize(file, config); - //} var jsonString = JsonSerializer.Serialize(config, new JsonSerializerOptions { WriteIndented = true }); File.WriteAllText(configFile, jsonString); From 56d020e42ec27dc7a936a6e26691802d29f0c17c Mon Sep 17 00:00:00 2001 From: Ty Conner Date: Sat, 6 May 2023 00:04:20 -0400 Subject: [PATCH 10/22] Update Program_Setup.cs --- Source/ACE.Server/Program_Setup.cs | 27 ++++++++++++++++++++++++++- 1 file changed, 26 insertions(+), 1 deletion(-) diff --git a/Source/ACE.Server/Program_Setup.cs b/Source/ACE.Server/Program_Setup.cs index 986b4ed5f7..8cdf1a5280 100644 --- a/Source/ACE.Server/Program_Setup.cs +++ b/Source/ACE.Server/Program_Setup.cs @@ -15,7 +15,32 @@ partial class Program { private static void DoOutOfBoxSetup(string configFile) { - var config = new MasterConfiguration(); + MasterConfiguration config; + + var exeLocation = Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location); + var configJsExample = Path.Combine(exeLocation, "Config.js.example"); + var exampleFile = new FileInfo(configJsExample); + if (!exampleFile.Exists) + { + config = new MasterConfiguration(); + } + else + { + if (!IsRunningInContainer) + { + Console.WriteLine("config.js Configuration file is missing, cloning from example file."); + File.Copy(configJsExample, configFile, true); + } + else + { + Console.WriteLine("config.js Configuration file is missing, ACEmulator is running in a container, cloning from docker file."); + var configJsDocker = Path.Combine(exeLocation, "Config.js.docker"); + File.Copy(configJsDocker, configFile, true); + } + + var fileText = File.ReadAllText(configFile); + config = JsonSerializer.Deserialize(fileText); + } Console.WriteLine("Performing setup for ACEmulator..."); Console.WriteLine(); From 4cb5f167d3f63ec2b1863e0f55d537eca1467124 Mon Sep 17 00:00:00 2001 From: Ty Conner Date: Sat, 6 May 2023 00:07:03 -0400 Subject: [PATCH 11/22] Update ACE.Adaptor Shift JSON weenie [de]serialization to System.Text.Json --- Source/ACE.Adapter/GDLE/GDLEConverter.cs | 54 +- Source/ACE.Adapter/GDLE/GDLELoader.cs | 2 +- Source/ACE.Adapter/GDLE/Models/Angles.cs | 17 +- Source/ACE.Adapter/GDLE/Models/ArmorValues.cs | 34 + Source/ACE.Adapter/GDLE/Models/Attribute.cs | 19 + .../ACE.Adapter/GDLE/Models/AttributeSet.cs | 37 + Source/ACE.Adapter/GDLE/Models/Body.cs | 12 + Source/ACE.Adapter/GDLE/Models/BodyPart.cs | 33 + .../GDLE/Models/BodyPartListing.cs | 36 + Source/ACE.Adapter/GDLE/Models/Book.cs | 18 + Source/ACE.Adapter/GDLE/Models/BoolStat.cs | 33 + .../ACE.Adapter/GDLE/Models/ChangelogEntry.cs | 17 + Source/ACE.Adapter/GDLE/Models/CreateItem.cs | 55 ++ Source/ACE.Adapter/GDLE/Models/DidStat.cs | 20 + Source/ACE.Adapter/GDLE/Models/Emote.cs | 96 +++ Source/ACE.Adapter/GDLE/Models/EmoteAction.cs | 373 +++++++++ .../GDLE/Models/EmoteCategoryListing.cs | 18 + Source/ACE.Adapter/GDLE/Models/FloatStat.cs | 20 + Source/ACE.Adapter/GDLE/Models/Frame.cs | 9 +- .../ACE.Adapter/GDLE/Models/GeneratorTable.cs | 77 ++ Source/ACE.Adapter/GDLE/Models/IidStat.cs | 20 + Source/ACE.Adapter/GDLE/Models/Int64Stat.cs | 20 + Source/ACE.Adapter/GDLE/Models/IntStat.cs | 191 +++++ Source/ACE.Adapter/GDLE/Models/LSDWeenie.cs | 716 ++++++++++++++++++ Source/ACE.Adapter/GDLE/Models/Metadata.cs | 2 +- Source/ACE.Adapter/GDLE/Models/Origin.cs | 13 +- Source/ACE.Adapter/GDLE/Models/Page.cs | 50 ++ Source/ACE.Adapter/GDLE/Models/Position.cs | 9 +- .../GDLE/Models/PositionListing.cs | 21 + Source/ACE.Adapter/GDLE/Models/Quaternion.cs | 60 ++ Source/ACE.Adapter/GDLE/Models/Skill.cs | 45 ++ .../ACE.Adapter/GDLE/Models/SkillListing.cs | 20 + .../GDLE/Models/SpellCastingStats.cs | 10 + .../ACE.Adapter/GDLE/Models/SpellbookEntry.cs | 25 + Source/ACE.Adapter/GDLE/Models/StringStat.cs | 20 + Source/ACE.Adapter/GDLE/Models/Vital.cs | 34 + Source/ACE.Adapter/GDLE/Models/XYZ.cs | 50 ++ Source/ACE.Adapter/GDLE/Models/Zones.cs | 30 + .../Lifestoned/LifestonedConverter.cs | 165 ++-- .../Lifestoned/LifestonedLoader.cs | 18 +- 40 files changed, 2370 insertions(+), 129 deletions(-) create mode 100644 Source/ACE.Adapter/GDLE/Models/ArmorValues.cs create mode 100644 Source/ACE.Adapter/GDLE/Models/Attribute.cs create mode 100644 Source/ACE.Adapter/GDLE/Models/AttributeSet.cs create mode 100644 Source/ACE.Adapter/GDLE/Models/Body.cs create mode 100644 Source/ACE.Adapter/GDLE/Models/BodyPart.cs create mode 100644 Source/ACE.Adapter/GDLE/Models/BodyPartListing.cs create mode 100644 Source/ACE.Adapter/GDLE/Models/Book.cs create mode 100644 Source/ACE.Adapter/GDLE/Models/BoolStat.cs create mode 100644 Source/ACE.Adapter/GDLE/Models/ChangelogEntry.cs create mode 100644 Source/ACE.Adapter/GDLE/Models/CreateItem.cs create mode 100644 Source/ACE.Adapter/GDLE/Models/DidStat.cs create mode 100644 Source/ACE.Adapter/GDLE/Models/Emote.cs create mode 100644 Source/ACE.Adapter/GDLE/Models/EmoteAction.cs create mode 100644 Source/ACE.Adapter/GDLE/Models/EmoteCategoryListing.cs create mode 100644 Source/ACE.Adapter/GDLE/Models/FloatStat.cs create mode 100644 Source/ACE.Adapter/GDLE/Models/GeneratorTable.cs create mode 100644 Source/ACE.Adapter/GDLE/Models/IidStat.cs create mode 100644 Source/ACE.Adapter/GDLE/Models/Int64Stat.cs create mode 100644 Source/ACE.Adapter/GDLE/Models/IntStat.cs create mode 100644 Source/ACE.Adapter/GDLE/Models/LSDWeenie.cs create mode 100644 Source/ACE.Adapter/GDLE/Models/Page.cs create mode 100644 Source/ACE.Adapter/GDLE/Models/PositionListing.cs create mode 100644 Source/ACE.Adapter/GDLE/Models/Quaternion.cs create mode 100644 Source/ACE.Adapter/GDLE/Models/Skill.cs create mode 100644 Source/ACE.Adapter/GDLE/Models/SkillListing.cs create mode 100644 Source/ACE.Adapter/GDLE/Models/SpellCastingStats.cs create mode 100644 Source/ACE.Adapter/GDLE/Models/SpellbookEntry.cs create mode 100644 Source/ACE.Adapter/GDLE/Models/StringStat.cs create mode 100644 Source/ACE.Adapter/GDLE/Models/Vital.cs create mode 100644 Source/ACE.Adapter/GDLE/Models/XYZ.cs create mode 100644 Source/ACE.Adapter/GDLE/Models/Zones.cs diff --git a/Source/ACE.Adapter/GDLE/GDLEConverter.cs b/Source/ACE.Adapter/GDLE/GDLEConverter.cs index ce818c466a..ff138b0bd8 100644 --- a/Source/ACE.Adapter/GDLE/GDLEConverter.cs +++ b/Source/ACE.Adapter/GDLE/GDLEConverter.cs @@ -68,22 +68,22 @@ public static bool TryConvert(List input, out Models.Landbloc // fix this ***, write it properly. var pos = new Models.Position(); - pos.objcell_id = lbi.ObjCellId; + pos.LandCellId = lbi.ObjCellId; var frame = new Models.Frame(); - frame.origin = new Models.Origin(); - frame.origin.x = lbi.OriginX; - frame.origin.y = lbi.OriginY; - frame.origin.z = lbi.OriginZ; + frame.Position = new Models.XYZ(); + frame.Position.X = lbi.OriginX; + frame.Position.Y = lbi.OriginY; + frame.Position.Z = lbi.OriginZ; - frame.angles = new Models.Angles(); - frame.angles.w = lbi.AnglesW; - frame.angles.x = lbi.AnglesX; - frame.angles.y = lbi.AnglesY; - frame.angles.z = lbi.AnglesZ; + frame.Rotations = new Models.Quaternion(); + frame.Rotations.W = lbi.AnglesW; + frame.Rotations.X = lbi.AnglesX; + frame.Rotations.Y = lbi.AnglesY; + frame.Rotations.Z = lbi.AnglesZ; - pos.frame = frame; + pos.Frame = frame; weenie.pos = pos; result.value.weenies.Add(weenie); @@ -139,14 +139,14 @@ public static bool TryConvert(Models.Landblock input, out List> 16) result.WeenieClassId = value.wcid; - result.ObjCellId = value.pos.objcell_id; - result.OriginX = value.pos.frame.origin.x; - result.OriginY = value.pos.frame.origin.y; - result.OriginZ = value.pos.frame.origin.z; - result.AnglesW = value.pos.frame.angles.w; - result.AnglesX = value.pos.frame.angles.x; - result.AnglesY = value.pos.frame.angles.y; - result.AnglesZ = value.pos.frame.angles.z; + result.ObjCellId = value.pos.LandCellId; + result.OriginX = value.pos.Frame.Position.X; + result.OriginY = value.pos.Frame.Position.Y; + result.OriginZ = value.pos.Frame.Position.Z; + result.AnglesW = value.pos.Frame.Rotations.W; + result.AnglesX = value.pos.Frame.Rotations.X; + result.AnglesY = value.pos.Frame.Rotations.Y; + result.AnglesZ = value.pos.Frame.Rotations.Z; results.Add(result); } @@ -352,16 +352,16 @@ public static bool TryConvert(uint id, Models.SpellValue input, out Spell result // PortalSending, FellowPortalSending if (input.MetaSpell.Spell.Position != null) { - result.PositionObjCellId = input.MetaSpell.Spell.Position.objcell_id; + result.PositionObjCellId = input.MetaSpell.Spell.Position.LandCellId; - result.PositionOriginX = input.MetaSpell.Spell.Position.frame.origin.x; - result.PositionOriginY = input.MetaSpell.Spell.Position.frame.origin.y; - result.PositionOriginZ = input.MetaSpell.Spell.Position.frame.origin.z; + result.PositionOriginX = input.MetaSpell.Spell.Position.Frame.Position.X; + result.PositionOriginY = input.MetaSpell.Spell.Position.Frame.Position.Y; + result.PositionOriginZ = input.MetaSpell.Spell.Position.Frame.Position.Z; - result.PositionAnglesW = input.MetaSpell.Spell.Position.frame.angles.w; - result.PositionAnglesX = input.MetaSpell.Spell.Position.frame.angles.x; - result.PositionAnglesY = input.MetaSpell.Spell.Position.frame.angles.y; - result.PositionAnglesZ = input.MetaSpell.Spell.Position.frame.angles.z; + result.PositionAnglesW = input.MetaSpell.Spell.Position.Frame.Rotations.W; + result.PositionAnglesX = input.MetaSpell.Spell.Position.Frame.Rotations.X; + result.PositionAnglesY = input.MetaSpell.Spell.Position.Frame.Rotations.Y; + result.PositionAnglesZ = input.MetaSpell.Spell.Position.Frame.Rotations.Z; } // Dispel, FellowDispel diff --git a/Source/ACE.Adapter/GDLE/GDLELoader.cs b/Source/ACE.Adapter/GDLE/GDLELoader.cs index 47dd0912c1..2bb4ed0135 100644 --- a/Source/ACE.Adapter/GDLE/GDLELoader.cs +++ b/Source/ACE.Adapter/GDLE/GDLELoader.cs @@ -113,7 +113,7 @@ private static void ReGuidAndConvertLandblocks(out List resul foreach (var weenie in landblock.value.weenies) { - var newGuid = (0x70000000 | ((weenie.pos.objcell_id & 0xFFFF0000) >> 4) | currentOffset); + var newGuid = (0x70000000 | ((weenie.pos.LandCellId & 0xFFFF0000) >> 4) | currentOffset); currentOffset++; if (!idChanges[landblock.key].ContainsKey(weenie.id)) diff --git a/Source/ACE.Adapter/GDLE/Models/Angles.cs b/Source/ACE.Adapter/GDLE/Models/Angles.cs index 75c572642c..bdcec89303 100644 --- a/Source/ACE.Adapter/GDLE/Models/Angles.cs +++ b/Source/ACE.Adapter/GDLE/Models/Angles.cs @@ -1,10 +1,19 @@ +using System.Text.Json.Serialization; + namespace ACE.Adapter.GDLE.Models { public class Angles { - public float w { get; set; } - public float x { get; set; } - public float y { get; set; } - public float z { get; set; } + [JsonPropertyName("w")] + public float W { get; set; } + + [JsonPropertyName("x")] + public float X { get; set; } + + [JsonPropertyName("y")] + public float Y { get; set; } + + [JsonPropertyName("z")] + public float Z { get; set; } } } diff --git a/Source/ACE.Adapter/GDLE/Models/ArmorValues.cs b/Source/ACE.Adapter/GDLE/Models/ArmorValues.cs new file mode 100644 index 0000000000..13037b16c0 --- /dev/null +++ b/Source/ACE.Adapter/GDLE/Models/ArmorValues.cs @@ -0,0 +1,34 @@ +using System.Text.Json.Serialization; + +namespace ACE.Adapter.GDLE.Models +{ + public class ArmorValues + { + [JsonPropertyName("base_armor")] + public int BaseArmor { get; set; } + + [JsonPropertyName("armor_vs_slash")] + public int ArmorVsSlash { get; set; } + + [JsonPropertyName("armor_vs_pierce")] + public int ArmorVsPierce { get; set; } + + [JsonPropertyName("armor_vs_bludgeon")] + public int ArmorVsBludgeon { get; set; } + + [JsonPropertyName("armor_vs_cold")] + public int ArmorVsCold { get; set; } + + [JsonPropertyName("armor_vs_fire")] + public int ArmorVsFire { get; set; } + + [JsonPropertyName("armor_vs_acid")] + public int ArmorVsAcid { get; set; } + + [JsonPropertyName("armor_vs_electric")] + public int ArmorVsElectric { get; set; } + + [JsonPropertyName("armor_vs_nether")] + public int ArmorVsNether { get; set; } + } +} diff --git a/Source/ACE.Adapter/GDLE/Models/Attribute.cs b/Source/ACE.Adapter/GDLE/Models/Attribute.cs new file mode 100644 index 0000000000..ad0646c897 --- /dev/null +++ b/Source/ACE.Adapter/GDLE/Models/Attribute.cs @@ -0,0 +1,19 @@ +using System.Text.Json.Serialization; + +namespace ACE.Adapter.GDLE.Models +{ + public class Attribute + { + [JsonPropertyName("cp_spent")] + public uint? XpSpent { get; set; } = 0u; + + + [JsonPropertyName("level_from_cp")] + public uint LevelFromCp { get; set; } = 0u; + + + [JsonPropertyName("init_level")] + public uint? Ranks { get; set; } = 0u; + + } +} diff --git a/Source/ACE.Adapter/GDLE/Models/AttributeSet.cs b/Source/ACE.Adapter/GDLE/Models/AttributeSet.cs new file mode 100644 index 0000000000..70cb061b58 --- /dev/null +++ b/Source/ACE.Adapter/GDLE/Models/AttributeSet.cs @@ -0,0 +1,37 @@ +using System.Text.Json.Serialization; + +namespace ACE.Adapter.GDLE.Models +{ + public class AttributeSet + { + [JsonPropertyName("strength")] + public Attribute Strength { get; set; } + + [JsonPropertyName("endurance")] + public Attribute Endurance { get; set; } + + [JsonPropertyName("coordination")] + public Attribute Coordination { get; set; } + + [JsonPropertyName("quickness")] + public Attribute Quickness { get; set; } + + [JsonPropertyName("focus")] + public Attribute Focus { get; set; } + + [JsonPropertyName("self")] + public Attribute Self { get; set; } + + [JsonPropertyName("health")] + public Vital Health { get; set; } = new Vital(); + + + [JsonPropertyName("stamina")] + public Vital Stamina { get; set; } = new Vital(); + + + [JsonPropertyName("mana")] + public Vital Mana { get; set; } = new Vital(); + + } +} diff --git a/Source/ACE.Adapter/GDLE/Models/Body.cs b/Source/ACE.Adapter/GDLE/Models/Body.cs new file mode 100644 index 0000000000..f8684481d9 --- /dev/null +++ b/Source/ACE.Adapter/GDLE/Models/Body.cs @@ -0,0 +1,12 @@ +using System.Collections.Generic; +using System.Text.Json.Serialization; + +namespace ACE.Adapter.GDLE.Models +{ + public class Body + { + [JsonPropertyName("body_part_table")] + public List BodyParts { get; set; } = new List(); + + } +} diff --git a/Source/ACE.Adapter/GDLE/Models/BodyPart.cs b/Source/ACE.Adapter/GDLE/Models/BodyPart.cs new file mode 100644 index 0000000000..84f8e606b1 --- /dev/null +++ b/Source/ACE.Adapter/GDLE/Models/BodyPart.cs @@ -0,0 +1,33 @@ +using System.Text.Json.Serialization; + +namespace ACE.Adapter.GDLE.Models +{ + public class BodyPart + { + [JsonPropertyName("dtype")] + public int DType { get; set; } + + + [JsonPropertyName("dval")] + public int DVal { get; set; } + + [JsonPropertyName("dvar")] + public float DVar { get; set; } + + [JsonPropertyName("acache")] + public ArmorValues ArmorValues { get; set; } + + [JsonPropertyName("bh")] + public int BH { get; set; } + + [JsonPropertyName("bpsd")] + public Zones SD { get; set; } + + + public BodyPart() + { + ArmorValues = new ArmorValues(); + SD = new Zones(); + } + } +} diff --git a/Source/ACE.Adapter/GDLE/Models/BodyPartListing.cs b/Source/ACE.Adapter/GDLE/Models/BodyPartListing.cs new file mode 100644 index 0000000000..6a234f3237 --- /dev/null +++ b/Source/ACE.Adapter/GDLE/Models/BodyPartListing.cs @@ -0,0 +1,36 @@ +using Lifestoned.DataModel.Shared; +using System.Text.Json.Serialization; + +namespace ACE.Adapter.GDLE.Models +{ + public class BodyPartListing + { + [JsonPropertyName("key")] + public int Key { get; set; } + + [JsonIgnore] + public BodyPartType BodyPartType + { + get + { + return (BodyPartType)Key; + } + set + { + Key = (int)value; + } + } + + [JsonPropertyName("value")] + public BodyPart BodyPart { get; set; } = new BodyPart(); + + + [JsonIgnore] + public bool Deleted { get; set; } + + public BodyPartListing() + { + BodyPart = new BodyPart(); + } + } +} diff --git a/Source/ACE.Adapter/GDLE/Models/Book.cs b/Source/ACE.Adapter/GDLE/Models/Book.cs new file mode 100644 index 0000000000..d72e2dc50a --- /dev/null +++ b/Source/ACE.Adapter/GDLE/Models/Book.cs @@ -0,0 +1,18 @@ +using System.Collections.Generic; +using System.Text.Json.Serialization; + +namespace ACE.Adapter.GDLE.Models +{ + public class Book + { + [JsonPropertyName("maxNumCharsPerPage")] + public int MaxCharactersPerPage { get; set; } + + [JsonPropertyName("maxNumPages")] + public int MaxNumberPages { get; set; } + + [JsonPropertyName("pages")] + public List Pages { get; set; } = new List(); + + } +} diff --git a/Source/ACE.Adapter/GDLE/Models/BoolStat.cs b/Source/ACE.Adapter/GDLE/Models/BoolStat.cs new file mode 100644 index 0000000000..cac33ecf93 --- /dev/null +++ b/Source/ACE.Adapter/GDLE/Models/BoolStat.cs @@ -0,0 +1,33 @@ +using Lifestoned.DataModel.Shared; +using System.Text.Json.Serialization; + +namespace ACE.Adapter.GDLE.Models +{ + public class BoolStat + { + [JsonPropertyName("key")] + public int Key { get; set; } + + [JsonPropertyName("value")] + public int Value { get; set; } + + [JsonIgnore] + public bool BoolValue + { + get + { + return Value != 0; + } + set + { + Value = (value ? 1 : 0); + } + } + + [JsonIgnore] + public string PropertyIdBinder => ((BoolPropertyId)Key).GetName(); + + [JsonIgnore] + public bool Deleted { get; set; } + } +} diff --git a/Source/ACE.Adapter/GDLE/Models/ChangelogEntry.cs b/Source/ACE.Adapter/GDLE/Models/ChangelogEntry.cs new file mode 100644 index 0000000000..38fd7a8a6e --- /dev/null +++ b/Source/ACE.Adapter/GDLE/Models/ChangelogEntry.cs @@ -0,0 +1,17 @@ +using System; +using System.Text.Json.Serialization; + +namespace ACE.Adapter.GDLE.Models +{ + public class ChangelogEntry + { + [JsonPropertyName("created")] + public DateTime Created { get; set; } + + [JsonPropertyName("author")] + public string Author { get; set; } + + [JsonPropertyName("comment")] + public string Comment { get; set; } + } +} diff --git a/Source/ACE.Adapter/GDLE/Models/CreateItem.cs b/Source/ACE.Adapter/GDLE/Models/CreateItem.cs new file mode 100644 index 0000000000..f92775116e --- /dev/null +++ b/Source/ACE.Adapter/GDLE/Models/CreateItem.cs @@ -0,0 +1,55 @@ +using Lifestoned.DataModel.Shared; +using System.Text.Json.Serialization; + +namespace ACE.Adapter.GDLE.Models +{ + public class CreateItem + { + [JsonPropertyName("wcid")] + public uint? WeenieClassId { get; set; } + + [JsonPropertyName("palette")] + public uint? Palette { get; set; } + + [JsonPropertyName("shade")] + public double? Shade { get; set; } + + [JsonPropertyName("destination")] + public uint? Destination { get; set; } + + [JsonIgnore] + public Destination? Destination_Binder + { + get + { + return (Destination?)Destination; + } + set + { + Destination = (uint?)value; + } + } + + [JsonPropertyName("stack_size")] + public int? StackSize { get; set; } + + [JsonPropertyName("try_to_bond")] + public byte? TryToBond { get; set; } + + [JsonIgnore] + public bool TryToBond_BooleanBinder + { + get + { + return TryToBond != 0; + } + set + { + TryToBond = (byte)(value ? 1u : 0u); + } + } + + [JsonIgnore] + public bool Deleted { get; set; } + } +} diff --git a/Source/ACE.Adapter/GDLE/Models/DidStat.cs b/Source/ACE.Adapter/GDLE/Models/DidStat.cs new file mode 100644 index 0000000000..752f5317b6 --- /dev/null +++ b/Source/ACE.Adapter/GDLE/Models/DidStat.cs @@ -0,0 +1,20 @@ +using Lifestoned.DataModel.Shared; +using System.Text.Json.Serialization; + +namespace ACE.Adapter.GDLE.Models +{ + public class DidStat + { + [JsonPropertyName("key")] + public int Key { get; set; } + + [JsonPropertyName("value")] + public uint Value { get; set; } + + [JsonIgnore] + public string PropertyIdBinder => ((DidPropertyId)Key).GetName(); + + [JsonIgnore] + public bool Deleted { get; set; } + } +} diff --git a/Source/ACE.Adapter/GDLE/Models/Emote.cs b/Source/ACE.Adapter/GDLE/Models/Emote.cs new file mode 100644 index 0000000000..8b77372160 --- /dev/null +++ b/Source/ACE.Adapter/GDLE/Models/Emote.cs @@ -0,0 +1,96 @@ +using Lifestoned.DataModel.Gdle; +using Lifestoned.DataModel.Shared; +using System; +using System.Collections.Generic; +using System.ComponentModel.DataAnnotations; +using System.Linq; +using System.Reflection; +using System.Text; +using System.Text.Json.Serialization; +using System.Threading.Tasks; +using System.Xml.Linq; + +namespace ACE.Adapter.GDLE.Models +{ + public class Emote + { + [JsonPropertyName("category")] + public uint Category { get; set; } + + [JsonIgnore] + [Display(Name = "Emote Category")] + public EmoteCategory EmoteCategory + { + get + { + return (EmoteCategory)Category; + } + set + { + Category = (uint)value; + } + } + + [JsonIgnore] + public EmoteType? NewEmoteType { get; set; } + + [JsonPropertyName("emotes")] + public List Actions { get; set; } + + [JsonPropertyName("probability")] + public float? Probability { get; set; } + + [JsonPropertyName("vendorType")] + [EmoteCategory(EmoteCategory.Vendor)] + public uint? VendorType { get; set; } + + [JsonPropertyName("quest")] + [EmoteCategory(EmoteCategory.QuestFailure)] + [EmoteCategory(EmoteCategory.QuestSuccess)] + [EmoteCategory(EmoteCategory.ReceiveTalkDirect)] + [EmoteCategory(EmoteCategory.TestSuccess)] + [EmoteCategory(EmoteCategory.TestFailure)] + [EmoteCategory(EmoteCategory.GotoSet)] + [EmoteCategory(EmoteCategory.QuestNoFellow)] + public string Quest { get; set; } + + [JsonPropertyName("classID")] + [EmoteCategory(EmoteCategory.Refuse)] + [EmoteCategory(EmoteCategory.Give)] + public uint? ClassId { get; set; } + + [JsonPropertyName("style")] + [EmoteCategory(EmoteCategory.HeartBeat)] + public uint? Style { get; set; } + + [JsonPropertyName("substyle")] + [EmoteCategory(EmoteCategory.HeartBeat)] + public uint? SubStyle { get; set; } + + [JsonPropertyName("minhealth")] + [EmoteCategory(EmoteCategory.WoundedTaunt)] + public float? MinHealth { get; set; } + + [JsonPropertyName("maxhealth")] + [EmoteCategory(EmoteCategory.WoundedTaunt)] + public float? MaxHealth { get; set; } + + [JsonIgnore] + public int? SortOrder { get; set; } + + [JsonIgnore] + public bool Deleted { get; set; } + + public static bool IsPropertyVisible(string propertyName, Emote emote) + { + PropertyInfo property = typeof(Emote).GetProperty(propertyName); + List list = property.GetCustomAttributes(typeof(EmoteCategoryAttribute), inherit: false).Cast().ToList(); + if (list == null || list.Count < 1) + { + return true; + } + + return list.Any((EmoteCategoryAttribute a) => a.CategoryList.Contains(emote.EmoteCategory)); + } + } +} diff --git a/Source/ACE.Adapter/GDLE/Models/EmoteAction.cs b/Source/ACE.Adapter/GDLE/Models/EmoteAction.cs new file mode 100644 index 0000000000..708d90a4f1 --- /dev/null +++ b/Source/ACE.Adapter/GDLE/Models/EmoteAction.cs @@ -0,0 +1,373 @@ +using Lifestoned.DataModel.Shared; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Reflection; +using System.Text; +using System.Text.Json.Serialization; +using System.Threading.Tasks; + +namespace ACE.Adapter.GDLE.Models +{ + public class EmoteAction + { + [JsonPropertyName("type")] + public uint EmoteActionType { get; set; } + + [JsonIgnore] + public EmoteType EmoteActionType_Binder + { + get + { + return (EmoteType)EmoteActionType; + } + set + { + EmoteActionType = (uint)value; + } + } + + [JsonPropertyName("delay")] + public float? Delay { get; set; } + + [JsonPropertyName("extent")] + public float? Extent { get; set; } + + [JsonPropertyName("amount")] + [EmoteType(EmoteType.DecrementQuest)] + [EmoteType(EmoteType.IncrementQuest)] + [EmoteType(EmoteType.SetQuestCompletions)] + [EmoteType(EmoteType.Generate)] + [EmoteType(EmoteType.DecrementMyQuest)] + [EmoteType(EmoteType.IncrementMyQuest)] + [EmoteType(EmoteType.SetMyQuestCompletions)] + [EmoteType(EmoteType.InqPackSpace)] + [EmoteType(EmoteType.InqQuestBitsOn)] + [EmoteType(EmoteType.InqQuestBitsOff)] + [EmoteType(EmoteType.InqMyQuestBitsOn)] + [EmoteType(EmoteType.InqMyQuestBitsOff)] + [EmoteType(EmoteType.SetQuestBitsOn)] + [EmoteType(EmoteType.SetQuestBitsOff)] + [EmoteType(EmoteType.SetMyQuestBitsOn)] + [EmoteType(EmoteType.SetMyQuestBitsOff)] + [EmoteType(EmoteType.SetIntStat)] + [EmoteType(EmoteType.IncrementIntStat)] + [EmoteType(EmoteType.DecrementIntStat)] + [EmoteType(EmoteType.SetBoolStat)] + [EmoteType(EmoteType.AddCharacterTitle)] + [EmoteType(EmoteType.AwardTrainingCredits)] + [EmoteType(EmoteType.InflictVitaePenalty)] + [EmoteType(EmoteType.RemoveVitaePenalty)] + [EmoteType(EmoteType.AddContract)] + [EmoteType(EmoteType.RemoveContract)] + [EmoteType(EmoteType.AwardSkillXP)] + [EmoteType(EmoteType.AwardSkillPoints)] + [EmoteType(EmoteType.SetAltRacialSkills)] + public uint? Amount { get; set; } + + [JsonPropertyName("motion")] + [EmoteType(EmoteType.Motion)] + [EmoteType(EmoteType.ForceMotion)] + public uint? Motion { get; set; } + + [JsonIgnore] + public MotionCommand? Motion_Binder + { + get + { + return (MotionCommand?)Motion; + } + set + { + Motion = (uint?)value; + } + } + + [JsonPropertyName("msg")] + [EmoteType(EmoteType.Act)] + [EmoteType(EmoteType.Say)] + [EmoteType(EmoteType.Tell)] + [EmoteType(EmoteType.TextDirect)] + [EmoteType(EmoteType.WorldBroadcast)] + [EmoteType(EmoteType.LocalBroadcast)] + [EmoteType(EmoteType.DirectBroadcast)] + [EmoteType(EmoteType.UpdateQuest)] + [EmoteType(EmoteType.InqQuest)] + [EmoteType(EmoteType.StampQuest)] + [EmoteType(EmoteType.StartEvent)] + [EmoteType(EmoteType.StopEvent)] + [EmoteType(EmoteType.BLog)] + [EmoteType(EmoteType.AdminSpam)] + [EmoteType(EmoteType.EraseQuest)] + [EmoteType(EmoteType.DecrementQuest)] + [EmoteType(EmoteType.IncrementQuest)] + [EmoteType(EmoteType.SetQuestCompletions)] + [EmoteType(EmoteType.InqEvent)] + [EmoteType(EmoteType.InqFellowQuest)] + [EmoteType(EmoteType.UpdateFellowQuest)] + [EmoteType(EmoteType.StampFellowQuest)] + [EmoteType(EmoteType.TellFellow)] + [EmoteType(EmoteType.FellowBroadcast)] + [EmoteType(EmoteType.Goto)] + [EmoteType(EmoteType.PopUp)] + [EmoteType(EmoteType.InqNumCharacterTitles)] + [EmoteType(EmoteType.UpdateMyQuest)] + [EmoteType(EmoteType.InqMyQuest)] + [EmoteType(EmoteType.StampMyQuest)] + [EmoteType(EmoteType.EraseMyQuest)] + [EmoteType(EmoteType.DecrementMyQuest)] + [EmoteType(EmoteType.IncrementMyQuest)] + [EmoteType(EmoteType.SetMyQuestCompletions)] + [EmoteType(EmoteType.LocalSignal)] + [EmoteType(EmoteType.InqPackSpace)] + [EmoteType(EmoteType.InqQuestBitsOn)] + [EmoteType(EmoteType.InqQuestBitsOff)] + [EmoteType(EmoteType.InqMyQuestBitsOn)] + [EmoteType(EmoteType.InqMyQuestBitsOff)] + [EmoteType(EmoteType.SetQuestBitsOn)] + [EmoteType(EmoteType.SetQuestBitsOff)] + [EmoteType(EmoteType.SetMyQuestBitsOn)] + [EmoteType(EmoteType.SetMyQuestBitsOff)] + [EmoteType(EmoteType.InqContractsFull)] + [EmoteType(EmoteType.InqQuestSolves)] + [EmoteType(EmoteType.InqFellowNum)] + [EmoteType(EmoteType.InqNumCharacterTitles)] + [EmoteType(EmoteType.InqMyQuestSolves)] + [EmoteType(EmoteType.InqOwnsItems)] + [EmoteType(EmoteType.InqBoolStat)] + [EmoteType(EmoteType.InqSkillTrained)] + [EmoteType(EmoteType.InqSkillSpecialized)] + [EmoteType(EmoteType.InqStringStat)] + [EmoteType(EmoteType.InqYesNo)] + [EmoteType(EmoteType.InqIntStat)] + [EmoteType(EmoteType.InqAttributeStat)] + [EmoteType(EmoteType.InqRawAttributeStat)] + [EmoteType(EmoteType.InqSecondaryAttributeStat)] + [EmoteType(EmoteType.InqRawSecondaryAttributeStat)] + [EmoteType(EmoteType.InqSkillStat)] + [EmoteType(EmoteType.InqRawSkillStat)] + [EmoteType(EmoteType.InqInt64Stat)] + [EmoteType(EmoteType.InqFloatStat)] + public string Message { get; set; } + + [JsonPropertyName("amount64")] + [EmoteType(EmoteType.AwardXP)] + [EmoteType(EmoteType.AwardNoShareXP)] + [EmoteType(EmoteType.SpendLuminance)] + [EmoteType(EmoteType.AwardLuminance)] + public long? Amount64 { get; set; } + + [JsonPropertyName("heroxp64")] + [EmoteType(EmoteType.AwardXP)] + [EmoteType(EmoteType.AwardNoShareXP)] + [EmoteType(EmoteType.SpendLuminance)] + public ulong? HeroXp64 { get; set; } + + [JsonPropertyName("cprof")] + [EmoteType(EmoteType.Give)] + [EmoteType(EmoteType.TakeItems)] + [EmoteType(EmoteType.InqOwnsItems)] + public CreateItem Item { get; set; } + + [JsonPropertyName("min64")] + [EmoteType(EmoteType.InqInt64Stat)] + [EmoteType(EmoteType.AwardLevelProportionalXP)] + public long? Minimum64 { get; set; } + + [JsonPropertyName("max64")] + [EmoteType(EmoteType.InqInt64Stat)] + [EmoteType(EmoteType.AwardLevelProportionalXP)] + public long? Maximum64 { get; set; } + + [JsonPropertyName("percent")] + [EmoteType(EmoteType.SetFloatStat)] + [EmoteType(EmoteType.AwardLevelProportionalXP)] + [EmoteType(EmoteType.AwardLevelProportionalSkillXP)] + public float? Percent { get; set; } + + [JsonPropertyName("display")] + [EmoteType(EmoteType.AwardLevelProportionalXP)] + [EmoteType(EmoteType.AwardLevelProportionalSkillXP)] + public byte? Display_Binder { get; set; } + + [JsonIgnore] + public bool? Display + { + get + { + return (!Display_Binder.HasValue) ? null : new bool?((Display_Binder.Value != 0) ? true : false); + } + set + { + Display_Binder = ((!value.HasValue) ? null : new byte?((byte)(value.Value ? 1 : 0))); + } + } + + [JsonPropertyName("max")] + [EmoteType(EmoteType.InqQuestSolves)] + [EmoteType(EmoteType.InqFellowNum)] + [EmoteType(EmoteType.InqNumCharacterTitles)] + [EmoteType(EmoteType.InqMyQuestSolves)] + [EmoteType(EmoteType.InqIntStat)] + [EmoteType(EmoteType.InqAttributeStat)] + [EmoteType(EmoteType.InqRawAttributeStat)] + [EmoteType(EmoteType.InqSecondaryAttributeStat)] + [EmoteType(EmoteType.InqRawSecondaryAttributeStat)] + [EmoteType(EmoteType.InqSkillStat)] + [EmoteType(EmoteType.InqRawSkillStat)] + [EmoteType(EmoteType.AwardLevelProportionalSkillXP)] + public uint? Max { get; set; } + + [JsonPropertyName("min")] + [EmoteType(EmoteType.InqQuestSolves)] + [EmoteType(EmoteType.InqFellowNum)] + [EmoteType(EmoteType.InqNumCharacterTitles)] + [EmoteType(EmoteType.InqMyQuestSolves)] + [EmoteType(EmoteType.InqIntStat)] + [EmoteType(EmoteType.InqAttributeStat)] + [EmoteType(EmoteType.InqRawAttributeStat)] + [EmoteType(EmoteType.InqSecondaryAttributeStat)] + [EmoteType(EmoteType.InqRawSecondaryAttributeStat)] + [EmoteType(EmoteType.InqSkillStat)] + [EmoteType(EmoteType.InqRawSkillStat)] + [EmoteType(EmoteType.AwardLevelProportionalSkillXP)] + public uint? Min { get; set; } + + [JsonPropertyName("fmax")] + [EmoteType(EmoteType.InqFloatStat)] + public float? FMax { get; set; } + + [JsonPropertyName("fmin")] + [EmoteType(EmoteType.InqFloatStat)] + public float? FMin { get; set; } + + [JsonPropertyName("stat")] + [EmoteType(EmoteType.SetIntStat)] + [EmoteType(EmoteType.IncrementIntStat)] + [EmoteType(EmoteType.DecrementIntStat)] + [EmoteType(EmoteType.SetBoolStat)] + [EmoteType(EmoteType.SetInt64Stat)] + [EmoteType(EmoteType.SetFloatStat)] + [EmoteType(EmoteType.AwardSkillXP)] + [EmoteType(EmoteType.AwardSkillPoints)] + [EmoteType(EmoteType.UntrainSkill)] + [EmoteType(EmoteType.InqBoolStat)] + [EmoteType(EmoteType.InqSkillTrained)] + [EmoteType(EmoteType.InqSkillSpecialized)] + [EmoteType(EmoteType.InqStringStat)] + [EmoteType(EmoteType.InqYesNo)] + [EmoteType(EmoteType.InqIntStat)] + [EmoteType(EmoteType.InqAttributeStat)] + [EmoteType(EmoteType.InqRawAttributeStat)] + [EmoteType(EmoteType.InqSecondaryAttributeStat)] + [EmoteType(EmoteType.InqRawSecondaryAttributeStat)] + [EmoteType(EmoteType.InqSkillStat)] + [EmoteType(EmoteType.InqRawSkillStat)] + [EmoteType(EmoteType.InqInt64Stat)] + [EmoteType(EmoteType.InqFloatStat)] + [EmoteType(EmoteType.AwardLevelProportionalSkillXP)] + public uint? Stat { get; set; } + + [JsonPropertyName("pscript")] + [EmoteType(EmoteType.PhysScript)] + public uint? PScript { get; set; } + + [JsonIgnore] + public PhysicsScriptType? PScript_Binder + { + get + { + return PScript.HasValue ? new PhysicsScriptType?((PhysicsScriptType)PScript.Value) : null; + } + set + { + PScript = (uint?)value; + } + } + + [JsonPropertyName("sound")] + [EmoteType(EmoteType.Sound)] + public uint? Sound { get; set; } + + [JsonPropertyName("mPosition")] + [EmoteType(EmoteType.SetSanctuaryPosition)] + [EmoteType(EmoteType.TeleportTarget)] + [EmoteType(EmoteType.TeleportSelf)] + public Position MPosition { get; set; } + + [JsonPropertyName("frame")] + [EmoteType(EmoteType.MoveHome)] + [EmoteType(EmoteType.Move)] + [EmoteType(EmoteType.Turn)] + [EmoteType(EmoteType.MoveToPos)] + public Frame Frame { get; set; } + + [JsonPropertyName("spellid")] + [EmoteType(EmoteType.CastSpell)] + [EmoteType(EmoteType.CastSpellInstant)] + [EmoteType(EmoteType.TeachSpell)] + [EmoteType(EmoteType.PetCastSpellOnOwner)] + public uint? SpellId { get; set; } + + [JsonPropertyName("teststring")] + [EmoteType(EmoteType.InqStringStat)] + [EmoteType(EmoteType.InqYesNo)] + public string TestString { get; set; } + + [JsonPropertyName("wealth_rating")] + [EmoteType(EmoteType.CreateTreasure)] + public uint? WealthRating { get; set; } + + [JsonIgnore] + public WealthRating? WealthRating_Binder + { + get + { + return (WealthRating?)WealthRating; + } + set + { + WealthRating = (uint?)value; + } + } + + [JsonPropertyName("treasure_class")] + [EmoteType(EmoteType.CreateTreasure)] + public uint? TreasureClass { get; set; } + + [JsonIgnore] + public TreasureClass? TreasureClass_Binder + { + get + { + return (TreasureClass?)TreasureClass; + } + set + { + TreasureClass = (uint?)value; + } + } + + [JsonPropertyName("treasure_type")] + [EmoteType(EmoteType.CreateTreasure)] + public int? TreasureType { get; set; } + + [JsonIgnore] + public int? SortOrder { get; set; } + + [JsonIgnore] + public bool Deleted { get; set; } + + public static bool IsPropertyVisible(string propertyName, EmoteAction emote) + { + PropertyInfo property = typeof(EmoteAction).GetProperty(propertyName); + List list = property.GetCustomAttributes(typeof(EmoteTypeAttribute), inherit: false).Cast().ToList(); + if (list == null || list.Count < 1) + { + return true; + } + + return list.Any((EmoteTypeAttribute a) => a.TypeList.Contains(emote.EmoteActionType_Binder)); + } + } +} diff --git a/Source/ACE.Adapter/GDLE/Models/EmoteCategoryListing.cs b/Source/ACE.Adapter/GDLE/Models/EmoteCategoryListing.cs new file mode 100644 index 0000000000..1a6509e396 --- /dev/null +++ b/Source/ACE.Adapter/GDLE/Models/EmoteCategoryListing.cs @@ -0,0 +1,18 @@ +using System.Collections.Generic; +using System.Text.Json.Serialization; + +namespace ACE.Adapter.GDLE.Models +{ + public class EmoteCategoryListing + { + [JsonPropertyName("key")] + public int EmoteCategoryId { get; set; } + + [JsonPropertyName("value")] + public List Emotes { get; set; } = new List(); + + + [JsonIgnore] + public bool Deleted { get; set; } + } +} diff --git a/Source/ACE.Adapter/GDLE/Models/FloatStat.cs b/Source/ACE.Adapter/GDLE/Models/FloatStat.cs new file mode 100644 index 0000000000..0c918eb8cc --- /dev/null +++ b/Source/ACE.Adapter/GDLE/Models/FloatStat.cs @@ -0,0 +1,20 @@ +using Lifestoned.DataModel.Shared; +using System.Text.Json.Serialization; + +namespace ACE.Adapter.GDLE.Models +{ + public class FloatStat + { + [JsonPropertyName("key")] + public int Key { get; set; } + + [JsonPropertyName("value")] + public float Value { get; set; } + + [JsonIgnore] + public string PropertyIdBinder => ((DoublePropertyId)Key).GetName(); + + [JsonIgnore] + public bool Deleted { get; set; } + } +} diff --git a/Source/ACE.Adapter/GDLE/Models/Frame.cs b/Source/ACE.Adapter/GDLE/Models/Frame.cs index 2984b0e67b..fa78574608 100644 --- a/Source/ACE.Adapter/GDLE/Models/Frame.cs +++ b/Source/ACE.Adapter/GDLE/Models/Frame.cs @@ -1,8 +1,13 @@ +using System.Text.Json.Serialization; + namespace ACE.Adapter.GDLE.Models { public class Frame { - public Origin origin { get; set; } - public Angles angles { get; set; } + [JsonPropertyName("origin")] + public XYZ Position { get; set; } + + [JsonPropertyName("angles")] + public Quaternion Rotations { get; set; } } } diff --git a/Source/ACE.Adapter/GDLE/Models/GeneratorTable.cs b/Source/ACE.Adapter/GDLE/Models/GeneratorTable.cs new file mode 100644 index 0000000000..83d775374e --- /dev/null +++ b/Source/ACE.Adapter/GDLE/Models/GeneratorTable.cs @@ -0,0 +1,77 @@ +using Lifestoned.DataModel.Shared; +using System.Text.Json.Serialization; + +namespace ACE.Adapter.GDLE.Models +{ + public class GeneratorTable + { + [JsonPropertyName("delay")] + public float Delay { get; set; } + + [JsonPropertyName("frame")] + public Frame Frame { get; set; } = new Frame(); + + + [JsonPropertyName("initCreate")] + public uint InitCreate { get; set; } + + [JsonPropertyName("maxNum")] + public uint MaxNumber { get; set; } + + [JsonPropertyName("objcell_id")] + public uint ObjectCell { get; set; } + + [JsonPropertyName("probability")] + public double Probability { get; set; } + + [JsonPropertyName("ptid")] + public uint PaletteId { get; set; } + + [JsonPropertyName("shade")] + public float Shade { get; set; } + + [JsonPropertyName("slot")] + public uint Slot { get; set; } + + [JsonPropertyName("stackSize")] + public int StackSize { get; set; } + + [JsonPropertyName("type")] + public uint WeenieClassId { get; set; } + + [JsonPropertyName("whenCreate")] + public uint WhenCreate { get; set; } + + [JsonPropertyName("whereCreate")] + public uint WhereCreate { get; set; } + + [JsonIgnore] + public RegenerationType WhenCreateEnum + { + get + { + return (RegenerationType)WhenCreate; + } + set + { + WhenCreate = (uint)value; + } + } + + [JsonIgnore] + public RegenerationLocation WhereCreateEnum + { + get + { + return (RegenerationLocation)WhereCreate; + } + set + { + WhereCreate = (uint)value; + } + } + + [JsonIgnore] + public bool Deleted { get; set; } + } +} diff --git a/Source/ACE.Adapter/GDLE/Models/IidStat.cs b/Source/ACE.Adapter/GDLE/Models/IidStat.cs new file mode 100644 index 0000000000..bef603b7ec --- /dev/null +++ b/Source/ACE.Adapter/GDLE/Models/IidStat.cs @@ -0,0 +1,20 @@ +using Lifestoned.DataModel.Shared; +using System.Text.Json.Serialization; + +namespace ACE.Adapter.GDLE.Models +{ + public class IidStat + { + [JsonPropertyName("key")] + public int Key { get; set; } + + [JsonPropertyName("value")] + public int Value { get; set; } + + [JsonIgnore] + public string PropertyIdBinder => ((IidPropertyId)Key).GetName(); + + [JsonIgnore] + public bool Deleted { get; set; } + } +} diff --git a/Source/ACE.Adapter/GDLE/Models/Int64Stat.cs b/Source/ACE.Adapter/GDLE/Models/Int64Stat.cs new file mode 100644 index 0000000000..f15ea099c7 --- /dev/null +++ b/Source/ACE.Adapter/GDLE/Models/Int64Stat.cs @@ -0,0 +1,20 @@ +using Lifestoned.DataModel.Shared; +using System.Text.Json.Serialization; + +namespace ACE.Adapter.GDLE.Models +{ + public class Int64Stat + { + [JsonPropertyName("key")] + public int Key { get; set; } + + [JsonPropertyName("value")] + public long Value { get; set; } + + [JsonIgnore] + public string PropertyIdBinder => ((Int64PropertyId)Key).GetName(); + + [JsonIgnore] + public bool Deleted { get; set; } + } +} diff --git a/Source/ACE.Adapter/GDLE/Models/IntStat.cs b/Source/ACE.Adapter/GDLE/Models/IntStat.cs new file mode 100644 index 0000000000..9c05a053bc --- /dev/null +++ b/Source/ACE.Adapter/GDLE/Models/IntStat.cs @@ -0,0 +1,191 @@ +using Lifestoned.DataModel.Shared; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text.Json.Serialization; + +namespace ACE.Adapter.GDLE.Models +{ + public class IntStat + { + [JsonPropertyName("key")] + public int Key { get; set; } + + [JsonPropertyName("value")] + public int Value { get; set; } + + [JsonIgnore] + public string[] MultiSelectRaw { get; set; } + + [JsonIgnore] + public string[] MultiSelect + { + get + { + int value = Value; + List list = new List(); + for (int j = 0; j <= 31; j++) + { + uint num = (uint)Math.Pow(2.0, j); + if ((num & value) != 0) + { + list.Add((int)num); + } + } + + return list.Select((int i) => i.ToString()).ToArray(); + } + set + { + MultiSelectRaw = value; + Value = 0; + if (value != null && value.Length >= 1) + { + foreach (string s in value) + { + Value += int.Parse(s); + } + } + } + } + + [JsonIgnore] + public string PropertyIdBinder => ((IntPropertyId)Key).GetName(); + + [JsonIgnore] + public ItemType? ItemTypeBoundValue + { + get + { + return (ItemType)Value; + } + set + { + Value = (int)value.Value; + } + } + + [JsonIgnore] + public WeenieType? WeenieTypeBoundValue + { + get + { + return (WeenieType)Value; + } + set + { + Value = (int)value.Value; + } + } + + [JsonIgnore] + public CreatureType? CreatureTypeBoundValue + { + get + { + return (CreatureType)Value; + } + set + { + Value = (int)value.Value; + } + } + + [JsonIgnore] + public ArmorType? ArmorTypeBoundValue + { + get + { + return (ArmorType)Value; + } + set + { + Value = (int)value.Value; + } + } + + [JsonIgnore] + public WieldRequirements? WieldRequirementsBoundValue + { + get + { + return (WieldRequirements)Value; + } + set + { + Value = (int)value.Value; + } + } + + [JsonIgnore] + public PaletteTemplate? PaletteTemplateBoundValue + { + get + { + return (PaletteTemplate)Value; + } + set + { + Value = (int)value.Value; + } + } + + [JsonIgnore] + public int? UiEffects { get; set; } + + [JsonIgnore] + public Material? Material_Binder + { + get + { + return (Material)Value; + } + set + { + Value = (int)value.Value; + } + } + + [JsonIgnore] + public HeritageGroup? HeritageBinder + { + get + { + return (HeritageGroup)Value; + } + set + { + Value = (int)value.Value; + } + } + + [JsonIgnore] + public WeaponType? WeaponTypeBoundValue + { + get + { + return (WeaponType)Value; + } + set + { + Value = (int)value.Value; + } + } + + [JsonIgnore] + public SkillId? SkillIdBoundValue + { + get + { + return (SkillId)Value; + } + set + { + Value = (int)value.Value; + } + } + + [JsonIgnore] + public bool Deleted { get; set; } + } +} diff --git a/Source/ACE.Adapter/GDLE/Models/LSDWeenie.cs b/Source/ACE.Adapter/GDLE/Models/LSDWeenie.cs new file mode 100644 index 0000000000..51b5bceaba --- /dev/null +++ b/Source/ACE.Adapter/GDLE/Models/LSDWeenie.cs @@ -0,0 +1,716 @@ +using Lifestoned.DataModel.DerethForever; +using Lifestoned.DataModel.Shared; +using System; +using System.Collections.Generic; +using System.ComponentModel.DataAnnotations; +using System.Linq; +using System.Reflection; +using System.Text.Json.Serialization; +using System.Xml.Linq; + +namespace ACE.Adapter.GDLE.Models +{ + public class LSDWeenie + { + //public class PropertyCopier where TParent : class where TChild : class + //{ + // public static void Copy(TParent parent, TChild child) + // { + // PropertyInfo[] properties = parent.GetType().GetProperties(); + // PropertyInfo[] properties2 = child.GetType().GetProperties(); + // PropertyInfo[] array = properties; + // foreach (PropertyInfo propertyInfo in array) + // { + // PropertyInfo[] array2 = properties2; + // foreach (PropertyInfo propertyInfo2 in array2) + // { + // if (propertyInfo.Name == propertyInfo2.Name && propertyInfo.PropertyType == propertyInfo2.PropertyType) + // { + // propertyInfo2.SetValue(child, propertyInfo.GetValue(parent)); + // break; + // } + // } + // } + // } + //} + + [JsonIgnore] + public bool IsCloneMode { get; set; } = false; + + + [JsonPropertyName("wcid")] + public uint WeenieId { get; set; } + + [JsonIgnore] + public uint WeenieClassId + { + get + { + return WeenieId; + } + set + { + WeenieId = value; + } + } + + [JsonPropertyName("weenieType")] + public int WeenieTypeId { get; set; } + + [JsonIgnore] + public WeenieType WeenieType_Binder + { + get + { + return (WeenieType)WeenieTypeId; + } + set + { + WeenieTypeId = (int)value; + } + } + + [JsonPropertyName("attributes")] + public AttributeSet Attributes { get; set; } + + [JsonPropertyName("body")] + public Body Body { get; set; } + + [JsonPropertyName("pageDataList")] + public Book Book { get; set; } + + [JsonPropertyName("boolStats")] + public List BoolStats { get; set; } = new List(); + + + [JsonPropertyName("intStats")] + public List IntStats { get; set; } = new List(); + + + [JsonPropertyName("didStats")] + public List DidStats { get; set; } = new List(); + + + [JsonPropertyName("iidStats")] + public List IidStats { get; set; } = new List(); + + + [JsonPropertyName("floatStats")] + public List FloatStats { get; set; } = new List(); + + + [JsonPropertyName("int64Stats")] + public List Int64Stats { get; set; } = new List(); + + + [JsonPropertyName("stringStats")] + public List StringStats { get; set; } = new List(); + + + [JsonPropertyName("createList")] + public List CreateList { get; set; } + + [JsonPropertyName("skills")] + public List Skills { get; set; } + + [JsonPropertyName("emoteTable")] + public List EmoteTable { get; set; } + + [JsonPropertyName("spellbook")] + public List Spells { get; set; } + + [JsonPropertyName("posStats")] + public List Positions { get; set; } + + [JsonPropertyName("generatorTable")] + public List GeneratorTable { get; set; } + + [JsonIgnore] + public string Name => StringStats?.FirstOrDefault((StringStat p) => p.Key == 1)?.Value ?? WeenieId.ToString(); + + [JsonIgnore] + public int? ItemType => IntStats.FirstOrDefault((IntStat d) => d.Key == 1)?.Value ?? 0; + + [JsonIgnore] + public bool HasAbilities => (ItemType & 0x10u) > 0; + + [JsonIgnore] + public bool HasGeneratorTable + { + get + { + List generatorTable = GeneratorTable; + return generatorTable != null && generatorTable.Count > 0; + } + } + + [JsonIgnore] + public bool HasBodyPartList => (Body?.BodyParts.Count() ?? 0) > 0; + + [JsonIgnore] + public int? UIEffects => IntStats.FirstOrDefault((IntStat d) => d.Key == 18)?.Value ?? 0; + + [JsonIgnore] + public uint? IconId => DidStats.FirstOrDefault((DidStat d) => d.Key == 8)?.Value; + + [JsonIgnore] + public uint? UnderlayId => DidStats.FirstOrDefault((DidStat d) => d.Key == 52)?.Value; + + [JsonIgnore] + public uint? OverlayId => DidStats.FirstOrDefault((DidStat d) => d.Key == 50)?.Value; + + [JsonIgnore] + public uint? OverlaySecondaryId => DidStats.FirstOrDefault((DidStat d) => d.Key == 51)?.Value; + + [JsonIgnore] + public WeenieCommands? MvcAction { get; set; } + + [JsonIgnore] + public string PropertyTab { get; set; } + + [JsonIgnore] + public IntPropertyId? NewIntPropertyId { get; set; } + + [JsonIgnore] + public StringPropertyId? NewStringPropertyId { get; set; } + + [JsonIgnore] + public Int64PropertyId? NewInt64PropertyId { get; set; } + + [JsonIgnore] + public DoublePropertyId? NewDoublePropertyId { get; set; } + + [JsonIgnore] + public DidPropertyId? NewDidPropertyId { get; set; } + + [JsonIgnore] + public IidPropertyId? NewIidPropertyId { get; set; } + + [JsonIgnore] + public BoolPropertyId? NewBoolPropertyId { get; set; } + + [JsonIgnore] + public SpellId? NewSpellId { get; set; } + + [JsonIgnore] + public PositionType? NewPositionType { get; set; } + + [JsonIgnore] + public SkillId? NewSkillId { get; set; } + + [JsonIgnore] + public SkillStatus? NewSkillStatus { get; set; } + + [JsonIgnore] + public BodyPartType? NewBodyPartType { get; set; } + + [JsonIgnore] + public EmoteCategory NewEmoteCategory { get; set; } + + [JsonIgnore] + public int? EmoteSetGuid { get; set; } + + [JsonPropertyName("lastModified")] + [Display(Name = "Last Modified Date")] + public DateTime? LastModified { get; set; } + + [JsonPropertyName("modifiedBy")] + [Display(Name = "Last Modified By")] + public string ModifiedBy { get; set; } + + [JsonPropertyName("changelog")] + public List Changelog { get; set; } = new List(); + + + [JsonPropertyName("userChangeSummary")] + public string UserChangeSummary { get; set; } + + [JsonPropertyName("isDone")] + [Display(Name = "Is Done")] + public bool IsDone { get; set; } + + [JsonPropertyName("comments")] + public string Comments { get; set; } + + //public void CleanDeletedAndEmptyProperties() + //{ + // StringStats?.RemoveAll((StringStat x) => x == null || x.Deleted || string.IsNullOrEmpty(x.Value)); + // IntStats?.RemoveAll((IntStat x) => x?.Deleted ?? true); + // Int64Stats?.RemoveAll((Int64Stat x) => x?.Deleted ?? true); + // FloatStats?.RemoveAll((FloatStat x) => x?.Deleted ?? true); + // BoolStats?.RemoveAll((BoolStat x) => x?.Deleted ?? true); + // DidStats?.RemoveAll((DidStat x) => x?.Deleted ?? true); + // Spells?.RemoveAll((SpellbookEntry x) => x?.Deleted ?? true); + // Book?.Pages?.RemoveAll((Page x) => x?.Deleted ?? true); + // Positions?.RemoveAll((PositionListing x) => x?.Deleted ?? true); + // EmoteTable?.ForEach(delegate (EmoteCategoryListing es) + // { + // es?.Emotes?.ForEach(delegate (Emote esa) + // { + // esa?.Actions?.RemoveAll((EmoteAction x) => x?.Deleted ?? true); + // }); + // }); + // EmoteTable?.ForEach(delegate (EmoteCategoryListing es) + // { + // es?.Emotes?.RemoveAll((Emote x) => x?.Deleted ?? true); + // }); + // EmoteTable?.RemoveAll(delegate (EmoteCategoryListing x) + // { + // int result; + // if (x != null && !x.Deleted) + // { + // List emotes = x.Emotes; + // result = ((emotes != null && emotes.Count < 1) ? 1 : 0); + // } + // else + // { + // result = 1; + // } + + // return (byte)result != 0; + // }); + // Body?.BodyParts?.RemoveAll((BodyPartListing x) => x?.Deleted ?? true); + // GeneratorTable?.RemoveAll((GeneratorTable x) => x?.Deleted ?? true); + // CreateList?.RemoveAll((CreateItem x) => x?.Deleted ?? true); + // Skills?.RemoveAll((SkillListing x) => x?.Deleted ?? true); + // IntStats?.RemoveAll((IntStat x) => x.Key == 9007); + // if (!HasAbilities) + // { + // Attributes = null; + // } + //} + + //public static Weenie ConvertFromWeenie(Lifestoned.DataModel.DerethForever.Weenie df) + //{ + // Weenie gdle = new Weenie + // { + // WeenieId = df.WeenieClassId, + // WeenieTypeId = df.IntProperties.First((IntProperty i) => i.IntPropertyId == 9007).Value.Value, + // IsDone = df.IsDone, + // Comments = df.Comments, + // UserChangeSummary = df.UserChangeSummary, + // Changelog = df.Changelog?.ToList(), + // ModifiedBy = df.ModifiedBy, + // LastModified = df.LastModified + // }; + // List intProperties = df.IntProperties; + // if (intProperties != null && intProperties.Count > 0) + // { + // gdle.IntStats = new List(); + // } + + // df.IntProperties?.Where((IntProperty ip) => ip.Value.HasValue).ToList().ForEach(delegate (IntProperty ip) + // { + // gdle.IntStats.Add(new IntStat + // { + // Key = ip.IntPropertyId, + // Value = ip.Value.Value + // }); + // }); + // List int64Properties = df.Int64Properties; + // if (int64Properties != null && int64Properties.Count > 0) + // { + // gdle.Int64Stats = new List(); + // } + + // df.Int64Properties?.Where((Int64Property ip) => ip.Value.HasValue).ToList().ForEach(delegate (Int64Property ip) + // { + // gdle.Int64Stats.Add(new Int64Stat + // { + // Key = ip.Int64PropertyId, + // Value = ip.Value.Value + // }); + // }); + // List doubleProperties = df.DoubleProperties; + // if (doubleProperties != null && doubleProperties.Count > 0) + // { + // gdle.FloatStats = new List(); + // } + + // df.DoubleProperties?.Where((DoubleProperty dp) => dp.Value.HasValue).ToList().ForEach(delegate (DoubleProperty dp) + // { + // gdle.FloatStats.Add(new FloatStat + // { + // Key = dp.DoublePropertyId, + // Value = (float)dp.Value.Value + // }); + // }); + // List boolProperties = df.BoolProperties; + // if (boolProperties != null && boolProperties.Count > 0) + // { + // gdle.BoolStats = new List(); + // } + + // df.BoolProperties?.ForEach(delegate (BoolProperty bp) + // { + // gdle.BoolStats.Add(new BoolStat + // { + // Key = bp.BoolPropertyId, + // BoolValue = bp.Value + // }); + // }); + // List didProperties = df.DidProperties; + // if (didProperties != null && didProperties.Count > 0) + // { + // gdle.DidStats = new List(); + // } + + // df.DidProperties?.Where((DataIdProperty dp) => dp.Value.HasValue).ToList().ForEach(delegate (DataIdProperty dp) + // { + // gdle.DidStats.Add(new DidStat + // { + // Key = dp.DataIdPropertyId, + // Value = dp.Value.Value + // }); + // }); + // List iidProperties = df.IidProperties; + // if (iidProperties != null && iidProperties.Count > 0) + // { + // gdle.IidStats = new List(); + // } + + // df.IidProperties?.Where((InstanceIdProperty dp) => dp.Value.HasValue).ToList().ForEach(delegate (InstanceIdProperty dp) + // { + // gdle.IidStats.Add(new IidStat + // { + // Key = dp.IidPropertyId, + // Value = dp.Value.Value + // }); + // }); + // List stringProperties = df.StringProperties; + // if (stringProperties != null && stringProperties.Count > 0) + // { + // gdle.StringStats = new List(); + // } + + // df.StringProperties?.ForEach(delegate (StringProperty sp) + // { + // gdle.StringStats.Add(new StringStat + // { + // Key = sp.StringPropertyId, + // Value = sp.Value + // }); + // }); + // if (df.BookProperties.Count > 0) + // { + // gdle.Book = new Book + // { + // Pages = new List(), + // MaxCharactersPerPage = 1000 + // }; + // df.BookProperties.ForEach(delegate (BookPage bp) + // { + // gdle.Book.Pages.Add(new Page + // { + // AuthorAccount = bp.AuthorAccount, + // AuthorId = bp.AuthorId, + // AuthorName = bp.AuthorName, + // IgnoreAuthor = bp.IgnoreAuthor, + // PageText = bp.PageText.Replace("\r\n", "\n").Replace("\r\n\r\n", "\n") + // }); + // }); + // gdle.Book.MaxNumberPages = gdle.Book.Pages.Count; + // } + + // if (df.HasAbilities) + // { + // gdle.Attributes = new AttributeSet + // { + // Strength = Attribute.Convert(df.Abilities.Strength), + // Endurance = Attribute.Convert(df.Abilities.Endurance), + // Coordination = Attribute.Convert(df.Abilities.Coordination), + // Quickness = Attribute.Convert(df.Abilities.Quickness), + // Focus = Attribute.Convert(df.Abilities.Focus), + // Self = Attribute.Convert(df.Abilities.Self), + // Health = Vital.Convert(df.Vitals.Health), + // Stamina = Vital.Convert(df.Vitals.Stamina), + // Mana = Vital.Convert(df.Vitals.Mana) + // }; + // List skills = df.Skills; + // if (skills != null && skills.Count > 0) + // { + // gdle.Skills = new List(); + // } + + // df.Skills.ForEach(delegate (Lifestoned.DataModel.DerethForever.Skill s) + // { + // gdle.Skills.Add(new SkillListing + // { + // SkillId = s.SkillId, + // Skill = new Skill + // { + // Ranks = s.Ranks, + // TrainedLevel = s.Status, + // XpInvested = (s.ExperienceSpent ?? 0), + // ResistanceOfLastCheck = 0u, + // LevelFromPp = 0u, + // LastUsed = 0f + // } + // }); + // }); + // } + + // List positions = df.Positions; + // if (positions != null && positions.Count > 0) + // { + // gdle.Positions = new List(); + // } + + // df.Positions?.ForEach(delegate (Lifestoned.DataModel.DerethForever.Position p) + // { + // gdle.Positions.Add(new PositionListing + // { + // PositionType = p.PositionType, + // Position = new Position + // { + // Frame = new Frame + // { + // Position = new XYZ + // { + // X = p.X, + // Y = p.Y, + // Z = p.Z + // }, + // Rotations = new Quaternion + // { + // W = p.QW, + // X = p.QX, + // Y = p.QY, + // Z = p.QZ + // } + // }, + // LandCellId = p.Landblock + // } + // }); + // }); + // List spells = df.Spells; + // if (spells != null && spells.Count > 0) + // { + // gdle.Spells = new List(); + // } + + // df.Spells?.ForEach(delegate (Spell s) + // { + // gdle.Spells.Add(new SpellbookEntry + // { + // SpellId = s.SpellId, + // Stats = new SpellCastingStats + // { + // CastingChance = s.Probability + // } + // }); + // }); + // List createList = df.CreateList; + // if (createList != null && createList.Count > 0) + // { + // gdle.CreateList = new List(); + // } + + // df.CreateList?.ForEach(delegate (CreationProfile cl) + // { + // gdle.CreateList.Add(new CreateItem + // { + // Destination = cl.Destination, + // Palette = cl.Palette, + // Shade = cl.Shade, + // StackSize = cl.StackSize, + // TryToBond = (byte)((cl.TryToBond.HasValue && cl.TryToBond.Value) ? 1 : 0), + // WeenieClassId = cl.WeenieClassId + // }); + // }); + // List generatorTable = df.GeneratorTable; + // if (generatorTable != null && generatorTable.Count > 0) + // { + // gdle.GeneratorTable = new List(); + // } + + // df.GeneratorTable?.ForEach(delegate (Lifestoned.DataModel.DerethForever.GeneratorTable gt) + // { + // GeneratorTable generatorTable2 = new GeneratorTable + // { + // Delay = gt.Delay, + // InitCreate = gt.InitCreate, + // MaxNumber = gt.MaxNumber, + // ObjectCell = gt.ObjectCell, + // PaletteId = gt.PaletteId, + // Probability = gt.Probability, + // Shade = gt.Shade, + // Slot = gt.Slot, + // StackSize = gt.StackSize, + // WeenieClassId = gt.WeenieClassId, + // WhenCreate = gt.WhenCreate, + // WhereCreate = gt.WhereCreate + // }; + // generatorTable2.Frame = new Frame + // { + // Position = new XYZ(), + // Rotations = new Quaternion + // { + // W = gt.Frame.Angles.W, + // X = gt.Frame.Angles.X, + // Y = gt.Frame.Angles.Y, + // Z = gt.Frame.Angles.Z + // } + // }; + // generatorTable2.Frame.Position.X = gt.Frame.Origin.X; + // generatorTable2.Frame.Position.Y = gt.Frame.Origin.Y; + // generatorTable2.Frame.Position.X = gt.Frame.Origin.X; + // gdle.GeneratorTable.Add(generatorTable2); + // }); + // List emoteTable = df.EmoteTable; + // if (emoteTable != null && emoteTable.Count > 0) + // { + // gdle.EmoteTable = new List(); + // foreach (EmoteSet es in df.EmoteTable) + // { + // if (!gdle.EmoteTable.Any((EmoteCategoryListing et) => et.EmoteCategoryId == (int)es.EmoteCategoryId)) + // { + // gdle.EmoteTable.Add(new EmoteCategoryListing + // { + // EmoteCategoryId = (int)es.EmoteCategoryId, + // Emotes = new List() + // }); + // } + + // EmoteCategoryListing emoteCategoryListing = gdle.EmoteTable.First((EmoteCategoryListing et) => et.EmoteCategoryId == (int)es.EmoteCategoryId); + // Emote pwnEmote = new Emote + // { + // ClassId = es.ClassId, + // Category = es.EmoteCategoryId, + // MaxHealth = es.MaxHealth, + // MinHealth = es.MinHealth, + // Probability = es.Probability, + // Quest = es.Quest, + // Style = es.Style, + // SubStyle = es.SubStyle, + // VendorType = es.VendorType, + // Actions = new List() + // }; + // es.Emotes.ForEach(delegate (Lifestoned.DataModel.DerethForever.Emote dfEmote) + // { + // EmoteAction emoteAction = new EmoteAction + // { + // Amount = dfEmote.Amount, + // Amount64 = dfEmote.Amount64, + // Delay = dfEmote.Delay, + // Display = dfEmote.Display, + // EmoteActionType = dfEmote.EmoteTypeId, + // Extent = dfEmote.Extent, + // FMax = dfEmote.MaximumFloat, + // FMin = dfEmote.MinimumFloat, + // HeroXp64 = dfEmote.HeroXp64, + // Max = dfEmote.Maximum, + // Maximum64 = dfEmote.Maximum64, + // Message = dfEmote.Message, + // Min = dfEmote.Minimum, + // Minimum64 = dfEmote.Minimum64, + // Motion = dfEmote.MotionId, + // Percent = (float?)dfEmote.Percent, + // PScript = dfEmote.PhysicsScriptId, + // Sound = dfEmote.Sound, + // SpellId = dfEmote.SpellId, + // Stat = dfEmote.Stat, + // TestString = dfEmote.TestString, + // TreasureClass = dfEmote.TreasureClassId, + // TreasureType = (int?)dfEmote.TreasureType, + // WealthRating = dfEmote.WealthRatingId + // }; + // if (dfEmote.PositionLandBlockId.HasValue) + // { + // emoteAction.MPosition = new Position(); + // } + + // if (dfEmote.PositionX.HasValue) + // { + // emoteAction.MPosition = new Position(); + // emoteAction.MPosition.Frame = new Frame + // { + // Position = new XYZ + // { + // X = dfEmote.PositionX.Value, + // Y = dfEmote.PositionY.Value, + // Z = dfEmote.PositionZ.Value + // }, + // Rotations = new Quaternion + // { + // W = dfEmote.RotationW.Value, + // X = dfEmote.RotationX.Value, + // Y = dfEmote.RotationY.Value, + // Z = dfEmote.RotationZ.Value + // } + // }; + // } + + // if (dfEmote.CreationProfile != null && Lifestoned.DataModel.DerethForever.Emote.IsPropertyVisible("CreationProfile", dfEmote.EmoteType)) + // { + // emoteAction.Item = new CreateItem + // { + // Destination = dfEmote.CreationProfile.Destination, + // Palette = dfEmote.CreationProfile.Palette, + // Shade = dfEmote.CreationProfile.Shade, + // StackSize = dfEmote.CreationProfile.StackSize, + // TryToBond = ((dfEmote.CreationProfile.TryToBond.HasValue && dfEmote.CreationProfile.TryToBond.Value) ? new byte?(1) : new byte?(0)), + // WeenieClassId = dfEmote.CreationProfile.WeenieClassId + // }; + // } + + // pwnEmote.Actions.Add(emoteAction); + // }); + // emoteCategoryListing.Emotes.Add(pwnEmote); + // } + // } + + // List bodyParts = df.BodyParts; + // if (bodyParts != null && bodyParts.Count > 0) + // { + // gdle.Body = new Body + // { + // BodyParts = new List() + // }; + // } + + // df.BodyParts?.ForEach(delegate (Lifestoned.DataModel.DerethForever.BodyPart bp) + // { + // gdle.Body.BodyParts.Add(new BodyPartListing + // { + // Key = (int)bp.BodyPartType, + // BodyPart = new BodyPart + // { + // BH = bp.BodyHeight, + // DType = (int)bp.DamageType, + // DVal = bp.Damage, + // DVar = bp.DamageVariance, + // ArmorValues = new ArmorValues + // { + // ArmorVsAcid = bp.ArmorValues.Acid, + // ArmorVsBludgeon = bp.ArmorValues.Bludgeon, + // ArmorVsCold = bp.ArmorValues.Cold, + // ArmorVsElectric = bp.ArmorValues.Electric, + // ArmorVsFire = bp.ArmorValues.Fire, + // ArmorVsNether = bp.ArmorValues.Nether, + // ArmorVsPierce = bp.ArmorValues.Pierce, + // ArmorVsSlash = bp.ArmorValues.Slash, + // BaseArmor = bp.ArmorValues.Base + // }, + // SD = new Zones + // { + // HLB = bp.TargetingData.HighLeftBack, + // HLF = bp.TargetingData.HighLeftFront, + // HRB = bp.TargetingData.HighRightBack, + // HRF = bp.TargetingData.HighRightFront, + // LLB = bp.TargetingData.LowLeftBack, + // LLF = bp.TargetingData.LowLeftFront, + // LRB = bp.TargetingData.LowRightBack, + // LRF = bp.TargetingData.LowRightFront, + // MLB = bp.TargetingData.MidLeftBack, + // MLF = bp.TargetingData.MidLeftFront, + // MRB = bp.TargetingData.MidRightBack, + // MRF = bp.TargetingData.MidRightFront + // } + // } + // }); + // }); + // return gdle; + //} + } +} diff --git a/Source/ACE.Adapter/GDLE/Models/Metadata.cs b/Source/ACE.Adapter/GDLE/Models/Metadata.cs index f336aea2b7..5ae0d249fb 100644 --- a/Source/ACE.Adapter/GDLE/Models/Metadata.cs +++ b/Source/ACE.Adapter/GDLE/Models/Metadata.cs @@ -18,7 +18,7 @@ public class Metadata public bool IsDone { get; set; } - public Metadata(Weenie weenie) + public Metadata(LSDWeenie weenie) { LastModified = weenie.LastModified; ModifiedBy = weenie.ModifiedBy; diff --git a/Source/ACE.Adapter/GDLE/Models/Origin.cs b/Source/ACE.Adapter/GDLE/Models/Origin.cs index 80a53500e2..9fcda6f5cc 100644 --- a/Source/ACE.Adapter/GDLE/Models/Origin.cs +++ b/Source/ACE.Adapter/GDLE/Models/Origin.cs @@ -1,9 +1,16 @@ +using System.Text.Json.Serialization; + namespace ACE.Adapter.GDLE.Models { public class Origin { - public float x { get; set; } - public float y { get; set; } - public float z { get; set; } + [JsonPropertyName("x")] + public float X { get; set; } + + [JsonPropertyName("y")] + public float Y { get; set; } + + [JsonPropertyName("z")] + public float Z { get; set; } } } diff --git a/Source/ACE.Adapter/GDLE/Models/Page.cs b/Source/ACE.Adapter/GDLE/Models/Page.cs new file mode 100644 index 0000000000..af42570ee4 --- /dev/null +++ b/Source/ACE.Adapter/GDLE/Models/Page.cs @@ -0,0 +1,50 @@ +using System.Text.Json.Serialization; + +namespace ACE.Adapter.GDLE.Models +{ + public class Page + { + [JsonPropertyName("authorAccount")] + public string AuthorAccount = ""; + + private string pageText; + + [JsonPropertyName("authorID")] + public uint? AuthorId { get; set; } + + [JsonPropertyName("authorName")] + public string AuthorName { get; set; } + + [JsonPropertyName("ignoreAuthor")] + public byte? IgnoreAutor_Binder { get; set; } + + [JsonIgnore] + public bool? IgnoreAuthor + { + get + { + return (!IgnoreAutor_Binder.HasValue) ? null : new bool?((IgnoreAutor_Binder.Value == 0) ? true : false); + } + set + { + IgnoreAutor_Binder = ((!value.HasValue) ? null : new byte?((byte)(value.Value ? 1 : 0))); + } + } + + [JsonPropertyName("pageText")] + public string PageText + { + get + { + return pageText; + } + set + { + pageText = value.Replace("\r", ""); + } + } + + [JsonIgnore] + public bool Deleted { get; set; } + } +} diff --git a/Source/ACE.Adapter/GDLE/Models/Position.cs b/Source/ACE.Adapter/GDLE/Models/Position.cs index ee229fcfc2..51eb39a489 100644 --- a/Source/ACE.Adapter/GDLE/Models/Position.cs +++ b/Source/ACE.Adapter/GDLE/Models/Position.cs @@ -1,8 +1,13 @@ +using System.Text.Json.Serialization; + namespace ACE.Adapter.GDLE.Models { public class Position { - public Frame frame { get; set; } - public uint objcell_id { get; set; } + [JsonPropertyName("frame")] + public Frame Frame { get; set; } + + [JsonPropertyName("objcell_id")] + public uint LandCellId { get; set; } } } diff --git a/Source/ACE.Adapter/GDLE/Models/PositionListing.cs b/Source/ACE.Adapter/GDLE/Models/PositionListing.cs new file mode 100644 index 0000000000..7956bf6634 --- /dev/null +++ b/Source/ACE.Adapter/GDLE/Models/PositionListing.cs @@ -0,0 +1,21 @@ +using Lifestoned.DataModel.Shared; +using System.Text.Json.Serialization; + +namespace ACE.Adapter.GDLE.Models +{ + public class PositionListing + { + [JsonPropertyName("key")] + public int PositionType { get; set; } + + [JsonIgnore] + public string PositionTypeName => ((PositionType)PositionType).GetName(); + + [JsonPropertyName("value")] + public Position Position { get; set; } = new Position(); + + + [JsonIgnore] + public bool Deleted { get; set; } + } +} diff --git a/Source/ACE.Adapter/GDLE/Models/Quaternion.cs b/Source/ACE.Adapter/GDLE/Models/Quaternion.cs new file mode 100644 index 0000000000..2641d7d643 --- /dev/null +++ b/Source/ACE.Adapter/GDLE/Models/Quaternion.cs @@ -0,0 +1,60 @@ +using System.Text.Json.Serialization; + +namespace ACE.Adapter.GDLE.Models +{ + public class Quaternion + { + [JsonPropertyName("w")] + public float W { get; set; } = 1f; + + + [JsonPropertyName("x")] + public float X { get; set; } + + [JsonPropertyName("y")] + public float Y { get; set; } + + [JsonPropertyName("z")] + public float Z { get; set; } + + [JsonIgnore] + public string Display + { + get + { + return $"{W:0.000000} {X:0.000000} {Y:0.000000} {Z:0.000000}"; + } + set + { + int startIndex = 0; + int num = value?.IndexOf(' ') ?? (-1); + if (num < 0) + { + W = 1f; + X = 0f; + Y = 0f; + Z = 0f; + return; + } + + float result = 0f; + float result2 = 0f; + float result3 = 0f; + float result4 = 0f; + float.TryParse(value.Substring(startIndex, num), out result); + startIndex = num + 1; + num = value.IndexOf(' ', startIndex); + float.TryParse(value.Substring(startIndex, num - startIndex), out result2); + startIndex = num + 1; + num = value.IndexOf(' ', startIndex); + float.TryParse(value.Substring(startIndex, num - startIndex), out result3); + startIndex = num + 1; + float.TryParse(value.Substring(startIndex), out result4); + W = result; + X = result2; + Y = result3; + Z = result4; + } + } + } +} diff --git a/Source/ACE.Adapter/GDLE/Models/Skill.cs b/Source/ACE.Adapter/GDLE/Models/Skill.cs new file mode 100644 index 0000000000..8a3b1760ba --- /dev/null +++ b/Source/ACE.Adapter/GDLE/Models/Skill.cs @@ -0,0 +1,45 @@ +using Lifestoned.DataModel.Shared; +using System.Text.Json.Serialization; + +namespace ACE.Adapter.GDLE.Models +{ + public class Skill + { + [JsonPropertyName("level_from_pp")] + public uint? LevelFromPp { get; set; } = 0u; + + + [JsonPropertyName("last_used_time")] + public float? LastUsed { get; set; } = 0f; + + + [JsonPropertyName("init_level")] + public uint? Ranks { get; set; } = 0u; + + + [JsonPropertyName("pp")] + public uint? XpInvested { get; set; } = 0u; + + + [JsonPropertyName("resistance_of_last_check")] + public uint? ResistanceOfLastCheck { get; set; } = 0u; + + + [JsonPropertyName("sac")] + public int? TrainedLevel { get; set; } = 0; + + + [JsonIgnore] + public SkillStatus? Status_Binder + { + get + { + return (SkillStatus?)TrainedLevel; + } + set + { + TrainedLevel = (int?)value; + } + } + } +} diff --git a/Source/ACE.Adapter/GDLE/Models/SkillListing.cs b/Source/ACE.Adapter/GDLE/Models/SkillListing.cs new file mode 100644 index 0000000000..10c3754c14 --- /dev/null +++ b/Source/ACE.Adapter/GDLE/Models/SkillListing.cs @@ -0,0 +1,20 @@ +using Lifestoned.DataModel.Shared; +using System.Text.Json.Serialization; + +namespace ACE.Adapter.GDLE.Models +{ + public class SkillListing + { + [JsonPropertyName("key")] + public int? SkillId { get; set; } + + [JsonPropertyName("value")] + public Skill Skill { get; set; } + + [JsonIgnore] + public string SkillName => ((SkillId?)SkillId).GetName(); + + [JsonIgnore] + public bool Deleted { get; set; } + } +} diff --git a/Source/ACE.Adapter/GDLE/Models/SpellCastingStats.cs b/Source/ACE.Adapter/GDLE/Models/SpellCastingStats.cs new file mode 100644 index 0000000000..f260e20a68 --- /dev/null +++ b/Source/ACE.Adapter/GDLE/Models/SpellCastingStats.cs @@ -0,0 +1,10 @@ +using System.Text.Json.Serialization; + +namespace ACE.Adapter.GDLE.Models +{ + public class SpellCastingStats + { + [JsonPropertyName("casting_likelihood")] + public double? CastingChance { get; set; } + } +} diff --git a/Source/ACE.Adapter/GDLE/Models/SpellbookEntry.cs b/Source/ACE.Adapter/GDLE/Models/SpellbookEntry.cs new file mode 100644 index 0000000000..5b7e622a6a --- /dev/null +++ b/Source/ACE.Adapter/GDLE/Models/SpellbookEntry.cs @@ -0,0 +1,25 @@ +using Lifestoned.DataModel.Shared; +using System.Text.Json.Serialization; +using System.Text.RegularExpressions; + +namespace ACE.Adapter.GDLE.Models +{ + public class SpellbookEntry + { + [JsonPropertyName("key")] + public int SpellId { get; set; } + + [JsonPropertyName("value")] + public SpellCastingStats Stats { get; set; } = new SpellCastingStats(); + + + [JsonIgnore] + public bool Deleted { get; set; } + + public string GetSpellDescription() + { + string input = ((SpellId)SpellId).ToString(); + return "(" + SpellId + ") " + Regex.Replace(input, "([A-Z0-9])", " $1", RegexOptions.Compiled).Trim(); + } + } +} diff --git a/Source/ACE.Adapter/GDLE/Models/StringStat.cs b/Source/ACE.Adapter/GDLE/Models/StringStat.cs new file mode 100644 index 0000000000..2ba96a1daf --- /dev/null +++ b/Source/ACE.Adapter/GDLE/Models/StringStat.cs @@ -0,0 +1,20 @@ +using Lifestoned.DataModel.Shared; +using System.Text.Json.Serialization; + +namespace ACE.Adapter.GDLE.Models +{ + public class StringStat + { + [JsonPropertyName("key")] + public int Key { get; set; } + + [JsonPropertyName("value")] + public string Value { get; set; } + + [JsonIgnore] + public string PropertyIdBinder => ((StringPropertyId)Key).GetName(); + + [JsonIgnore] + public bool Deleted { get; set; } + } +} diff --git a/Source/ACE.Adapter/GDLE/Models/Vital.cs b/Source/ACE.Adapter/GDLE/Models/Vital.cs new file mode 100644 index 0000000000..c72f6db491 --- /dev/null +++ b/Source/ACE.Adapter/GDLE/Models/Vital.cs @@ -0,0 +1,34 @@ +using Lifestoned.DataModel.DerethForever; +using System.Text.Json.Serialization; + +namespace ACE.Adapter.GDLE.Models +{ + public class Vital + { + [JsonPropertyName("cp_spent")] + public uint? XpSpent { get; set; } = 0u; + + + [JsonPropertyName("level_from_cp")] + public uint? LevelFromCp { get; set; } = 0u; + + + [JsonPropertyName("init_level")] + public uint? Ranks { get; set; } = 0u; + + + [JsonPropertyName("current")] + public uint? Current { get; set; } = 0u; + + + public static Vital Convert(Ability ability) + { + Vital vital = new Vital(); + vital.Ranks = ability.Ranks; + vital.Current = ability.Base + ability.Ranks; + vital.XpSpent = ability.ExperienceSpent; + vital.LevelFromCp = 0u; + return vital; + } + } +} diff --git a/Source/ACE.Adapter/GDLE/Models/XYZ.cs b/Source/ACE.Adapter/GDLE/Models/XYZ.cs new file mode 100644 index 0000000000..8b7cf57e2f --- /dev/null +++ b/Source/ACE.Adapter/GDLE/Models/XYZ.cs @@ -0,0 +1,50 @@ +using System.Text.Json.Serialization; + +namespace ACE.Adapter.GDLE.Models +{ + public class XYZ + { + [JsonPropertyName("x")] + public float X { get; set; } + + [JsonPropertyName("y")] + public float Y { get; set; } + + [JsonPropertyName("z")] + public float Z { get; set; } + + [JsonIgnore] + public string Display + { + get + { + return $"{X:0.000000} {Y:0.000000} {Z:0.000000}"; + } + set + { + int num = 0; + int num2 = value?.IndexOf(' ') ?? (-1); + if (num2 < 0) + { + X = 0f; + Y = 0f; + Z = 0f; + return; + } + + float result = 0f; + float result2 = 0f; + float result3 = 0f; + float.TryParse(value.Substring(num, num2 - num), out result); + num = num2 + 1; + num2 = value.IndexOf(' ', num); + float.TryParse(value.Substring(num, num2 - num), out result2); + num = num2 + 1; + float.TryParse(value.Substring(num), out result3); + X = result; + Y = result2; + Z = result3; + } + } + } +} diff --git a/Source/ACE.Adapter/GDLE/Models/Zones.cs b/Source/ACE.Adapter/GDLE/Models/Zones.cs new file mode 100644 index 0000000000..e24b751266 --- /dev/null +++ b/Source/ACE.Adapter/GDLE/Models/Zones.cs @@ -0,0 +1,30 @@ + +namespace ACE.Adapter.GDLE.Models +{ + public class Zones + { + public double? HLF { get; set; } + + public double? MLF { get; set; } + + public double? LLF { get; set; } + + public double? HRF { get; set; } + + public double? MRF { get; set; } + + public double? LRF { get; set; } + + public double? HLB { get; set; } + + public double? MLB { get; set; } + + public double? LLB { get; set; } + + public double? HRB { get; set; } + + public double? MRB { get; set; } + + public double? LRB { get; set; } + } +} diff --git a/Source/ACE.Adapter/Lifestoned/LifestonedConverter.cs b/Source/ACE.Adapter/Lifestoned/LifestonedConverter.cs index 2f74c42d88..7344daf2c1 100644 --- a/Source/ACE.Adapter/Lifestoned/LifestonedConverter.cs +++ b/Source/ACE.Adapter/Lifestoned/LifestonedConverter.cs @@ -1,8 +1,11 @@ using System; using System.Collections.Generic; using System.Linq; +using System.Text.Encodings.Web; using System.Text.Json; +using System.Text.Json.Serialization; using ACE.Adapter.Enum; +using ACE.Adapter.GDLE.Models; using ACE.Database.Models.World; using ACE.Entity.Enum; using ACE.Entity.Enum.Properties; @@ -14,7 +17,7 @@ public static class LifestonedConverter /// /// Converts LSD weenie to ACE weenie /// - public static bool TryConvert(global::Lifestoned.DataModel.Gdle.Weenie input, out Weenie result, bool correctForEnumShift = false) + public static bool TryConvert(LSDWeenie input, out Weenie result, bool correctForEnumShift = false) { if (input.WeenieId == 0) { @@ -483,7 +486,7 @@ public static bool TryConvert(global::Lifestoned.DataModel.Gdle.Weenie input, ou /// /// Converts ACE weenie to LSD weenie /// - public static bool TryConvert(Weenie input, out global::Lifestoned.DataModel.Gdle.Weenie result, bool correctForEnumShift = false) + public static bool TryConvert(Weenie input, out LSDWeenie result, bool correctForEnumShift = false) { if (input.ClassId == 0) { @@ -493,7 +496,7 @@ public static bool TryConvert(Weenie input, out global::Lifestoned.DataModel.Gdl try { - result = new global::Lifestoned.DataModel.Gdle.Weenie(); + result = new LSDWeenie(); result.WeenieId = input.ClassId; @@ -513,19 +516,19 @@ public static bool TryConvert(Weenie input, out global::Lifestoned.DataModel.Gdl if (input.WeeniePropertiesBook != null) { - result.Book = new global::Lifestoned.DataModel.Gdle.Book(); + result.Book = new Book(); result.Book.MaxNumberPages = input.WeeniePropertiesBook.MaxNumPages; result.Book.MaxCharactersPerPage = input.WeeniePropertiesBook.MaxNumCharsPerPage; if (input.WeeniePropertiesBookPageData != null && input.WeeniePropertiesBookPageData.Count > 0) { - result.Book.Pages = new List(); + result.Book.Pages = new List(); //uint pageId = 0; foreach (var value in input.WeeniePropertiesBookPageData.OrderBy(p => p.PageId)) { - result.Book.Pages.Add(new global::Lifestoned.DataModel.Gdle.Page + result.Book.Pages.Add(new Page { //= pageId, @@ -550,44 +553,44 @@ public static bool TryConvert(Weenie input, out global::Lifestoned.DataModel.Gdl if (input.WeeniePropertiesAttribute != null && input.WeeniePropertiesAttribute.Count > 0) { if (result.Attributes == null) - result.Attributes = new global::Lifestoned.DataModel.Gdle.AttributeSet(); + result.Attributes = new AttributeSet(); - result.Attributes.Strength = new global::Lifestoned.DataModel.Gdle.Attribute + result.Attributes.Strength = new GDLE.Models.Attribute { Ranks = input.WeeniePropertiesAttribute.FirstOrDefault(a => a.Type == (ushort)PropertyAttribute.Strength).InitLevel, LevelFromCp = input.WeeniePropertiesAttribute.FirstOrDefault(a => a.Type == (ushort)PropertyAttribute.Strength).LevelFromCP, XpSpent = input.WeeniePropertiesAttribute.FirstOrDefault(a => a.Type == (ushort)PropertyAttribute.Strength).CPSpent }; - result.Attributes.Endurance = new global::Lifestoned.DataModel.Gdle.Attribute + result.Attributes.Endurance = new GDLE.Models.Attribute { Ranks = input.WeeniePropertiesAttribute.FirstOrDefault(a => a.Type == (ushort)PropertyAttribute.Endurance).InitLevel, LevelFromCp = input.WeeniePropertiesAttribute.FirstOrDefault(a => a.Type == (ushort)PropertyAttribute.Endurance).LevelFromCP, XpSpent = input.WeeniePropertiesAttribute.FirstOrDefault(a => a.Type == (ushort)PropertyAttribute.Endurance).CPSpent }; - result.Attributes.Quickness = new global::Lifestoned.DataModel.Gdle.Attribute + result.Attributes.Quickness = new GDLE.Models.Attribute { Ranks = input.WeeniePropertiesAttribute.FirstOrDefault(a => a.Type == (ushort)PropertyAttribute.Quickness).InitLevel, LevelFromCp = input.WeeniePropertiesAttribute.FirstOrDefault(a => a.Type == (ushort)PropertyAttribute.Quickness).LevelFromCP, XpSpent = input.WeeniePropertiesAttribute.FirstOrDefault(a => a.Type == (ushort)PropertyAttribute.Quickness).CPSpent }; - result.Attributes.Coordination = new global::Lifestoned.DataModel.Gdle.Attribute + result.Attributes.Coordination = new GDLE.Models.Attribute { Ranks = input.WeeniePropertiesAttribute.FirstOrDefault(a => a.Type == (ushort)PropertyAttribute.Coordination).InitLevel, LevelFromCp = input.WeeniePropertiesAttribute.FirstOrDefault(a => a.Type == (ushort)PropertyAttribute.Coordination).LevelFromCP, XpSpent = input.WeeniePropertiesAttribute.FirstOrDefault(a => a.Type == (ushort)PropertyAttribute.Coordination).CPSpent }; - result.Attributes.Focus = new global::Lifestoned.DataModel.Gdle.Attribute + result.Attributes.Focus = new GDLE.Models.Attribute { Ranks = input.WeeniePropertiesAttribute.FirstOrDefault(a => a.Type == (ushort)PropertyAttribute.Focus).InitLevel, LevelFromCp = input.WeeniePropertiesAttribute.FirstOrDefault(a => a.Type == (ushort)PropertyAttribute.Focus).LevelFromCP, XpSpent = input.WeeniePropertiesAttribute.FirstOrDefault(a => a.Type == (ushort)PropertyAttribute.Focus).CPSpent }; - result.Attributes.Self = new global::Lifestoned.DataModel.Gdle.Attribute + result.Attributes.Self = new GDLE.Models.Attribute { Ranks = input.WeeniePropertiesAttribute.FirstOrDefault(a => a.Type == (ushort)PropertyAttribute.Self).InitLevel, LevelFromCp = input.WeeniePropertiesAttribute.FirstOrDefault(a => a.Type == (ushort)PropertyAttribute.Self).LevelFromCP, @@ -598,9 +601,9 @@ public static bool TryConvert(Weenie input, out global::Lifestoned.DataModel.Gdl if (input.WeeniePropertiesAttribute2nd != null && input.WeeniePropertiesAttribute2nd.Count > 0) { if (result.Attributes == null) - result.Attributes = new global::Lifestoned.DataModel.Gdle.AttributeSet(); + result.Attributes = new AttributeSet(); - result.Attributes.Health = new global::Lifestoned.DataModel.Gdle.Vital + result.Attributes.Health = new GDLE.Models.Vital { Ranks = input.WeeniePropertiesAttribute2nd.FirstOrDefault(a => a.Type == (ushort)PropertyAttribute2nd.MaxHealth).InitLevel, LevelFromCp = input.WeeniePropertiesAttribute2nd.FirstOrDefault(a => a.Type == (ushort)PropertyAttribute2nd.MaxHealth).LevelFromCP, @@ -608,7 +611,7 @@ public static bool TryConvert(Weenie input, out global::Lifestoned.DataModel.Gdl Current = input.WeeniePropertiesAttribute2nd.FirstOrDefault(a => a.Type == (ushort)PropertyAttribute2nd.MaxHealth).CurrentLevel }; - result.Attributes.Stamina = new global::Lifestoned.DataModel.Gdle.Vital + result.Attributes.Stamina = new GDLE.Models.Vital { Ranks = input.WeeniePropertiesAttribute2nd.FirstOrDefault(a => a.Type == (ushort)PropertyAttribute2nd.MaxStamina).InitLevel, LevelFromCp = input.WeeniePropertiesAttribute2nd.FirstOrDefault(a => a.Type == (ushort)PropertyAttribute2nd.MaxStamina).LevelFromCP, @@ -616,7 +619,7 @@ public static bool TryConvert(Weenie input, out global::Lifestoned.DataModel.Gdl Current = input.WeeniePropertiesAttribute2nd.FirstOrDefault(a => a.Type == (ushort)PropertyAttribute2nd.MaxStamina).CurrentLevel }; - result.Attributes.Mana = new global::Lifestoned.DataModel.Gdle.Vital + result.Attributes.Mana = new GDLE.Models.Vital { Ranks = input.WeeniePropertiesAttribute2nd.FirstOrDefault(a => a.Type == (ushort)PropertyAttribute2nd.MaxMana).InitLevel, LevelFromCp = input.WeeniePropertiesAttribute2nd.FirstOrDefault(a => a.Type == (ushort)PropertyAttribute2nd.MaxMana).LevelFromCP, @@ -627,21 +630,21 @@ public static bool TryConvert(Weenie input, out global::Lifestoned.DataModel.Gdl if (input.WeeniePropertiesBodyPart != null && input.WeeniePropertiesBodyPart.Count > 0) { - result.Body = new global::Lifestoned.DataModel.Gdle.Body(); - result.Body.BodyParts = new List(); + result.Body = new Body(); + result.Body.BodyParts = new List(); foreach (var value in input.WeeniePropertiesBodyPart) { - result.Body.BodyParts.Add(new global::Lifestoned.DataModel.Gdle.BodyPartListing + result.Body.BodyParts.Add(new BodyPartListing { Key = value.Key, BodyPartType = (global::Lifestoned.DataModel.Shared.BodyPartType)value.Key, - BodyPart = new global::Lifestoned.DataModel.Gdle.BodyPart + BodyPart = new BodyPart { DType = value.DType, DVal = value.DVal, DVar = value.DVar, - ArmorValues = new global::Lifestoned.DataModel.Gdle.ArmorValues + ArmorValues = new ArmorValues { BaseArmor = value.BaseArmor, ArmorVsSlash = value.ArmorVsSlash, @@ -654,7 +657,7 @@ public static bool TryConvert(Weenie input, out global::Lifestoned.DataModel.Gdl ArmorVsNether = value.ArmorVsNether }, BH = value.BH, - SD = new global::Lifestoned.DataModel.Gdle.Zones + SD = new Zones { HLF = value.HLF, MLF = value.MLF, @@ -679,21 +682,21 @@ public static bool TryConvert(Weenie input, out global::Lifestoned.DataModel.Gdl if (input.WeeniePropertiesBool != null && input.WeeniePropertiesBool.Count > 0) { - result.BoolStats = new List(); + result.BoolStats = new List(); foreach (var value in input.WeeniePropertiesBool) { if (result.BoolStats.FirstOrDefault(x => x.Key == value.Type) == null) - result.BoolStats.Add(new global::Lifestoned.DataModel.Gdle.BoolStat { Key = value.Type, Value = Convert.ToInt32(value.Value) }); + result.BoolStats.Add(new BoolStat { Key = value.Type, Value = Convert.ToInt32(value.Value) }); } } if (input.WeeniePropertiesCreateList != null && input.WeeniePropertiesCreateList.Count > 0) { - result.CreateList = new List(); + result.CreateList = new List(); foreach (var value in input.WeeniePropertiesCreateList) - result.CreateList.Add(new global::Lifestoned.DataModel.Gdle.CreateItem + result.CreateList.Add(new CreateItem { WeenieClassId = value.WeenieClassId, Palette = (uint)value.Palette, @@ -706,28 +709,28 @@ public static bool TryConvert(Weenie input, out global::Lifestoned.DataModel.Gdl if (input.WeeniePropertiesDID != null && input.WeeniePropertiesDID.Count > 0) { - result.DidStats = new List(); + result.DidStats = new List(); foreach (var value in input.WeeniePropertiesDID) { - result.DidStats.Add(new global::Lifestoned.DataModel.Gdle.DidStat { Key = value.Type, Value = value.Value }); + result.DidStats.Add(new DidStat { Key = value.Type, Value = value.Value }); } } if (input.WeeniePropertiesEmote != null && input.WeeniePropertiesEmote.Count > 0) { - result.EmoteTable = new List(); + result.EmoteTable = new List(); var eorder = 0; foreach (var emote in input.WeeniePropertiesEmote) { - var ec = new global::Lifestoned.DataModel.Gdle.EmoteCategoryListing + var ec = new EmoteCategoryListing { EmoteCategoryId = (int)emote.Category, - Emotes = new List(), + Emotes = new List(), }; - var em = new global::Lifestoned.DataModel.Gdle.Emote + var em = new Emote { SortOrder = eorder, Category = emote.Category, @@ -740,13 +743,13 @@ public static bool TryConvert(Weenie input, out global::Lifestoned.DataModel.Gdl Style = emote.Style, SubStyle = emote.Substyle, VendorType = (uint?)emote.VendorType, - Actions = new List() + Actions = new List() }; var aorder = 0; foreach (var action in emote.WeeniePropertiesEmoteAction.OrderBy(e => e.Order)) { - var ea = new global::Lifestoned.DataModel.Gdle.EmoteAction + var ea = new EmoteAction { SortOrder = aorder, Amount = (uint?)action.Amount, @@ -756,15 +759,15 @@ public static bool TryConvert(Weenie input, out global::Lifestoned.DataModel.Gdl Extent = action.Extent, FMax = (float?)action.MaxDbl, FMin = (float?)action.MinDbl, - //Frame = new global::Lifestoned.DataModel.Gdle.Frame + //Frame = new Frame //{ - // Position = new global::Lifestoned.DataModel.Gdle.XYZ + // Position = new XYZ // { // X = action.OriginX ?? 0, // Y = action.OriginY ?? 0, // Z = action.OriginZ ?? 0 // }, - // Rotations = new global::Lifestoned.DataModel.Gdle.Quaternion + // Rotations = new Quaternion // { // W = action.AnglesW ?? 0, // X = action.AnglesX ?? 0, @@ -773,7 +776,7 @@ public static bool TryConvert(Weenie input, out global::Lifestoned.DataModel.Gdl // } //}, HeroXp64 = (ulong?)action.HeroXP64, - //Item = new global::Lifestoned.DataModel.Gdle.CreateItem + //Item = new CreateItem //{ // Destination = (uint?)action.DestinationType, // Palette = (uint?)action.Palette, @@ -788,18 +791,18 @@ public static bool TryConvert(Weenie input, out global::Lifestoned.DataModel.Gdl Minimum64 = action.Min64, Message = action.Message, Motion = (uint?)action.Motion, - //MPosition = new global::Lifestoned.DataModel.Gdle.Position + //MPosition = new Position //{ // LandCellId = action.ObjCellId ?? 0, - // Frame = new global::Lifestoned.DataModel.Gdle.Frame + // Frame = new Frame // { - // Position = new global::Lifestoned.DataModel.Gdle.XYZ + // Position = new XYZ // { // X = action.OriginX ?? 0, // Y = action.OriginY ?? 0, // Z = action.OriginZ ?? 0 // }, - // Rotations = new global::Lifestoned.DataModel.Gdle.Quaternion + // Rotations = new Quaternion // { // W = action.AnglesW ?? 0, // X = action.AnglesX ?? 0, @@ -821,18 +824,18 @@ public static bool TryConvert(Weenie input, out global::Lifestoned.DataModel.Gdl if (action.ObjCellId.HasValue) { - ea.MPosition = new global::Lifestoned.DataModel.Gdle.Position + ea.MPosition = new Position { LandCellId = action.ObjCellId ?? 0, - Frame = new global::Lifestoned.DataModel.Gdle.Frame + Frame = new Frame { - Position = new global::Lifestoned.DataModel.Gdle.XYZ + Position = new XYZ { X = action.OriginX ?? 0, Y = action.OriginY ?? 0, Z = action.OriginZ ?? 0 }, - Rotations = new global::Lifestoned.DataModel.Gdle.Quaternion + Rotations = new Quaternion { W = action.AnglesW ?? 0, X = action.AnglesX ?? 0, @@ -844,15 +847,15 @@ public static bool TryConvert(Weenie input, out global::Lifestoned.DataModel.Gdl } else if (action.OriginX.HasValue || action.OriginY.HasValue || action.OriginZ.HasValue || action.AnglesW.HasValue || action.AnglesX.HasValue || action.AnglesY.HasValue || action.AnglesZ.HasValue) { - ea.Frame = new global::Lifestoned.DataModel.Gdle.Frame + ea.Frame = new Frame { - Position = new global::Lifestoned.DataModel.Gdle.XYZ + Position = new XYZ { X = action.OriginX ?? 0, Y = action.OriginY ?? 0, Z = action.OriginZ ?? 0 }, - Rotations = new global::Lifestoned.DataModel.Gdle.Quaternion + Rotations = new Quaternion { W = action.AnglesW ?? 0, X = action.AnglesX ?? 0, @@ -864,7 +867,7 @@ public static bool TryConvert(Weenie input, out global::Lifestoned.DataModel.Gdl if (action.DestinationType.HasValue) { - ea.Item = new global::Lifestoned.DataModel.Gdle.CreateItem + ea.Item = new CreateItem { Destination = (uint?)action.DestinationType, Palette = (uint?)action.Palette, @@ -900,17 +903,17 @@ public static bool TryConvert(Weenie input, out global::Lifestoned.DataModel.Gdl foreach (var value in input.WeeniePropertiesFloat) { if (result.FloatStats.FirstOrDefault(x => x.Key == value.Type) == null) - result.FloatStats.Add(new global::Lifestoned.DataModel.Gdle.FloatStat { Key = value.Type, Value = (float)value.Value }); + result.FloatStats.Add(new FloatStat { Key = value.Type, Value = (float)value.Value }); } } if (input.WeeniePropertiesGenerator != null && input.WeeniePropertiesGenerator.Count > 0) { - result.GeneratorTable = new List(); + result.GeneratorTable = new List(); uint slot = 0; foreach (var value in input.WeeniePropertiesGenerator) { - result.GeneratorTable.Add(new global::Lifestoned.DataModel.Gdle.GeneratorTable + result.GeneratorTable.Add(new GeneratorTable { Slot = slot, Probability = value.Probability, @@ -929,15 +932,15 @@ public static bool TryConvert(Weenie input, out global::Lifestoned.DataModel.Gdl Shade = value.Shade ?? 0, ObjectCell = value.ObjCellId ?? 0, - Frame = new global::Lifestoned.DataModel.Gdle.Frame + Frame = new Frame { - Position = new global::Lifestoned.DataModel.Gdle.XYZ + Position = new XYZ { X = value.OriginX ?? 0, Y = value.OriginY ?? 0, Z = value.OriginZ ?? 0 }, - Rotations = new global::Lifestoned.DataModel.Gdle.Quaternion + Rotations = new Quaternion { W = value.AnglesW ?? 0, X = value.AnglesX ?? 0, @@ -952,34 +955,34 @@ public static bool TryConvert(Weenie input, out global::Lifestoned.DataModel.Gdl if (input.WeeniePropertiesIID != null && input.WeeniePropertiesIID.Count > 0) { - result.IidStats = new List(); + result.IidStats = new List(); foreach (var value in input.WeeniePropertiesIID) { if (result.IidStats.FirstOrDefault(x => x.Key == value.Type) == null) - result.IidStats.Add(new global::Lifestoned.DataModel.Gdle.IidStat { Key = value.Type, Value = (int)value.Value }); + result.IidStats.Add(new IidStat { Key = value.Type, Value = (int)value.Value }); } } if (input.WeeniePropertiesInt != null && input.WeeniePropertiesInt.Count > 0) { - result.IntStats = new List(); + result.IntStats = new List(); foreach (var value in input.WeeniePropertiesInt) { if (result.IntStats.FirstOrDefault(x => x.Key == value.Type) == null) - result.IntStats.Add(new global::Lifestoned.DataModel.Gdle.IntStat { Key = value.Type, Value = value.Value }); + result.IntStats.Add(new IntStat { Key = value.Type, Value = value.Value }); } } if (input.WeeniePropertiesInt64 != null && input.WeeniePropertiesInt64.Count > 0) { - result.Int64Stats = new List(); + result.Int64Stats = new List(); foreach (var value in input.WeeniePropertiesInt64) { if (result.Int64Stats.FirstOrDefault(x => x.Key == value.Type) == null) - result.Int64Stats.Add(new global::Lifestoned.DataModel.Gdle.Int64Stat { Key = value.Type, Value = value.Value }); + result.Int64Stats.Add(new Int64Stat { Key = value.Type, Value = value.Value }); } } @@ -987,26 +990,26 @@ public static bool TryConvert(Weenie input, out global::Lifestoned.DataModel.Gdl if (input.WeeniePropertiesPosition != null && input.WeeniePropertiesPosition.Count > 0) { - result.Positions = new List(); + result.Positions = new List(); foreach (var value in input.WeeniePropertiesPosition) { if (result.Positions.FirstOrDefault(x => x.PositionType == value.PositionType) == null) - result.Positions.Add(new global::Lifestoned.DataModel.Gdle.PositionListing + result.Positions.Add(new PositionListing { PositionType = value.PositionType, - Position = new global::Lifestoned.DataModel.Gdle.Position + Position = new Position { LandCellId = value.ObjCellId, - Frame = new global::Lifestoned.DataModel.Gdle.Frame + Frame = new Frame { - Position = new global::Lifestoned.DataModel.Gdle.XYZ + Position = new XYZ { X = value.OriginX, Y = value.OriginY, Z = value.OriginZ, }, - Rotations = new global::Lifestoned.DataModel.Gdle.Quaternion + Rotations = new Quaternion { W = value.AnglesW, X = value.AnglesX, @@ -1021,15 +1024,15 @@ public static bool TryConvert(Weenie input, out global::Lifestoned.DataModel.Gdl if (input.WeeniePropertiesSkill != null && input.WeeniePropertiesSkill.Count > 0) { - result.Skills = new List(); + result.Skills = new List(); foreach (var value in input.WeeniePropertiesSkill) { if (result.Skills.FirstOrDefault(x => x.SkillId == value.Type) == null) - result.Skills.Add(new global::Lifestoned.DataModel.Gdle.SkillListing + result.Skills.Add(new SkillListing { SkillId = value.Type, - Skill = new global::Lifestoned.DataModel.Gdle.Skill + Skill = new GDLE.Models.Skill { LevelFromPp = value.LevelFromPP, TrainedLevel = (int)value.SAC, @@ -1044,15 +1047,15 @@ public static bool TryConvert(Weenie input, out global::Lifestoned.DataModel.Gdl if (input.WeeniePropertiesSpellBook != null && input.WeeniePropertiesSpellBook.Count > 0) { - result.Spells = new List(); + result.Spells = new List(); foreach (var value in input.WeeniePropertiesSpellBook) { if (result.Spells.FirstOrDefault(x => x.SpellId == value.Spell) == null) - result.Spells.Add(new global::Lifestoned.DataModel.Gdle.SpellbookEntry + result.Spells.Add(new SpellbookEntry { SpellId = value.Spell, - Stats = new global::Lifestoned.DataModel.Gdle.SpellCastingStats + Stats = new SpellCastingStats { CastingChance = value.Probability } @@ -1062,19 +1065,19 @@ public static bool TryConvert(Weenie input, out global::Lifestoned.DataModel.Gdl if (input.WeeniePropertiesString != null && input.WeeniePropertiesString.Count > 0) { - result.StringStats = new List(); + result.StringStats = new List(); foreach (var value in input.WeeniePropertiesString) { if (result.StringStats.FirstOrDefault(x => x.Key == value.Type) == null) - result.StringStats.Add(new global::Lifestoned.DataModel.Gdle.StringStat { Key = value.Type, Value = value.Value }); + result.StringStats.Add(new StringStat { Key = value.Type, Value = value.Value }); } } // WeeniePropertiesTextureMap - result.Changelog = new List(); - result.Changelog.Add(new global::Lifestoned.DataModel.Shared.ChangelogEntry + result.Changelog = new List(); + result.Changelog.Add(new ChangelogEntry { Author = "ACE.Adapter", Comment = "Weenie exported from ACEmulator world database using ACE.Adapter", @@ -1117,10 +1120,12 @@ public static bool TryConvertACEWeeniesToLSDJSON(List weenies, out List< static LifestonedConverter() { + SerializerSettings.DefaultIgnoreCondition = JsonIgnoreCondition.WhenWritingNull; + SerializerSettings.Encoder = JavaScriptEncoder.UnsafeRelaxedJsonEscaping; SerializerSettings.WriteIndented = true; } - public static bool TryConvertACEWeenieToLSDJSON(Weenie weenie, out string result, out global::Lifestoned.DataModel.Gdle.Weenie lsdWeenie) + public static bool TryConvertACEWeenieToLSDJSON(Weenie weenie, out string result, out LSDWeenie lsdWeenie) { try { diff --git a/Source/ACE.Adapter/Lifestoned/LifestonedLoader.cs b/Source/ACE.Adapter/Lifestoned/LifestonedLoader.cs index d5e4770e31..23c4223cf0 100644 --- a/Source/ACE.Adapter/Lifestoned/LifestonedLoader.cs +++ b/Source/ACE.Adapter/Lifestoned/LifestonedLoader.cs @@ -13,13 +13,13 @@ namespace ACE.Adapter.Lifestoned { public static class LifestonedLoader { - public static bool TryLoadWeenie(string file, out global::Lifestoned.DataModel.Gdle.Weenie result) + public static bool TryLoadWeenie(string file, out LSDWeenie result) { try { var fileText = File.ReadAllText(file); - result = JsonSerializer.Deserialize(fileText); + result = JsonSerializer.Deserialize(fileText); return true; } @@ -30,11 +30,11 @@ public static bool TryLoadWeenie(string file, out global::Lifestoned.DataModel.G } } - public static bool TryLoadWeenies(string folder, out List results) + public static bool TryLoadWeenies(string folder, out List results) { try { - results = new List(); + results = new List(); var files = Directory.GetFiles(folder, "*.json", SearchOption.AllDirectories).OrderByDescending(f => new FileInfo(f).CreationTime).ToList(); @@ -53,13 +53,13 @@ public static bool TryLoadWeenies(string folder, out List results) + public static bool TryLoadWeeniesInParallel(string folder, out List results) { try { var files = Directory.GetFiles(folder, "*.json", SearchOption.AllDirectories); - var weenies = new ConcurrentBag(); + var weenies = new ConcurrentBag(); Parallel.ForEach(files, file => { @@ -67,7 +67,7 @@ public static bool TryLoadWeeniesInParallel(string folder, out List(weenies); + results = new List(weenies); return true; } @@ -85,7 +85,7 @@ public static bool TryLoadWeenieConverted(string file, out Weenie result, bool c { var fileText = File.ReadAllText(file); - var lifestonedModel = JsonSerializer.Deserialize(fileText); + var lifestonedModel = JsonSerializer.Deserialize(fileText); return LifestonedConverter.TryConvert(lifestonedModel, out result, correctForEnumShift); } @@ -144,7 +144,7 @@ public static bool TryLoadWeeniesConvertedInParallel(string folder, out List Date: Sat, 6 May 2023 00:13:12 -0400 Subject: [PATCH 12/22] Update LifestonedConverter.cs --- Source/ACE.Adapter/Lifestoned/LifestonedConverter.cs | 1 + 1 file changed, 1 insertion(+) diff --git a/Source/ACE.Adapter/Lifestoned/LifestonedConverter.cs b/Source/ACE.Adapter/Lifestoned/LifestonedConverter.cs index 7344daf2c1..29b3e34e78 100644 --- a/Source/ACE.Adapter/Lifestoned/LifestonedConverter.cs +++ b/Source/ACE.Adapter/Lifestoned/LifestonedConverter.cs @@ -4,6 +4,7 @@ using System.Text.Encodings.Web; using System.Text.Json; using System.Text.Json.Serialization; + using ACE.Adapter.Enum; using ACE.Adapter.GDLE.Models; using ACE.Database.Models.World; From 8733476e560cabdb60546420907252b738a976e5 Mon Sep 17 00:00:00 2001 From: Ty Conner Date: Sat, 6 May 2023 00:15:00 -0400 Subject: [PATCH 13/22] Update StarterGearFactory.cs --- Source/ACE.Server/Factories/StarterGearFactory.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Source/ACE.Server/Factories/StarterGearFactory.cs b/Source/ACE.Server/Factories/StarterGearFactory.cs index 46aab6c468..d248cb70af 100644 --- a/Source/ACE.Server/Factories/StarterGearFactory.cs +++ b/Source/ACE.Server/Factories/StarterGearFactory.cs @@ -36,7 +36,7 @@ private static StarterGearConfiguration LoadConfigFromResource() { var starterGearText = File.ReadAllText(starterGearFile); - config = JsonSerializer.Deserialize(starterGearText, new JsonSerializerOptions { ReadCommentHandling = JsonCommentHandling.Skip, NumberHandling = JsonNumberHandling.AllowReadingFromString, }); + config = JsonSerializer.Deserialize(starterGearText, new JsonSerializerOptions { ReadCommentHandling = JsonCommentHandling.Skip, NumberHandling = JsonNumberHandling.AllowReadingFromString }); return config; } From 9d2a10ce4c6bd431c82ce8c4dee9f5a9f844f4bb Mon Sep 17 00:00:00 2001 From: Ty Conner Date: Sat, 16 Sep 2023 21:57:35 -0400 Subject: [PATCH 14/22] Update ACE.Server.csproj --- Source/ACE.Server/ACE.Server.csproj | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/Source/ACE.Server/ACE.Server.csproj b/Source/ACE.Server/ACE.Server.csproj index 82d53e3d90..ac3c0d88fd 100644 --- a/Source/ACE.Server/ACE.Server.csproj +++ b/Source/ACE.Server/ACE.Server.csproj @@ -237,11 +237,9 @@ - - - + From ace256b2a9aeb8e4bcdb156c78b16b50a34c5f9f Mon Sep 17 00:00:00 2001 From: Ty Conner Date: Sat, 16 Sep 2023 21:57:37 -0400 Subject: [PATCH 15/22] Update ACE.Server.Tests.csproj --- Source/ACE.Server.Tests/ACE.Server.Tests.csproj | 4 ---- 1 file changed, 4 deletions(-) diff --git a/Source/ACE.Server.Tests/ACE.Server.Tests.csproj b/Source/ACE.Server.Tests/ACE.Server.Tests.csproj index 283e7dd2f0..a6a1659d37 100644 --- a/Source/ACE.Server.Tests/ACE.Server.Tests.csproj +++ b/Source/ACE.Server.Tests/ACE.Server.Tests.csproj @@ -28,13 +28,9 @@ - - - - From 201c8e14ab8baff39a63e6e98e92a711bc5c04d0 Mon Sep 17 00:00:00 2001 From: Ty Conner Date: Sat, 16 Sep 2023 21:59:34 -0400 Subject: [PATCH 16/22] Update Program.cs --- Source/ACE.Server/Program.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Source/ACE.Server/Program.cs b/Source/ACE.Server/Program.cs index da04f336bc..c45dfd2eea 100644 --- a/Source/ACE.Server/Program.cs +++ b/Source/ACE.Server/Program.cs @@ -13,8 +13,8 @@ using ACE.DatLoader; using ACE.Server.Command; using ACE.Server.Managers; -using ACE.Server.Network.Managers; using ACE.Server.Mods; +using ACE.Server.Network.Managers; namespace ACE.Server { From 2e54e76cc36053ee0db8f0c491d186e0844906f8 Mon Sep 17 00:00:00 2001 From: Ty Conner Date: Sat, 16 Sep 2023 21:59:42 -0400 Subject: [PATCH 17/22] Update MySqlConfiguration.cs --- Source/ACE.Common/MySqlConfiguration.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Source/ACE.Common/MySqlConfiguration.cs b/Source/ACE.Common/MySqlConfiguration.cs index 0b0fac8a2b..1a6a69eec2 100644 --- a/Source/ACE.Common/MySqlConfiguration.cs +++ b/Source/ACE.Common/MySqlConfiguration.cs @@ -1,4 +1,4 @@ -using Newtonsoft.Json; +using System.Text.Json.Serialization; namespace ACE.Common { From ab46bdc6ff6c34090379e3c828eb576a9ab1d22c Mon Sep 17 00:00:00 2001 From: Ty Conner Date: Sat, 16 Sep 2023 22:16:55 -0400 Subject: [PATCH 18/22] Update DDDConfiguration.cs --- Source/ACE.Common/DDDConfiguration.cs | 13 ++----------- 1 file changed, 2 insertions(+), 11 deletions(-) diff --git a/Source/ACE.Common/DDDConfiguration.cs b/Source/ACE.Common/DDDConfiguration.cs index e32c2bfeef..e57da5c0d1 100644 --- a/Source/ACE.Common/DDDConfiguration.cs +++ b/Source/ACE.Common/DDDConfiguration.cs @@ -1,8 +1,3 @@ -using System; - -using System.Collections.Generic; -using Newtonsoft.Json; - namespace ACE.Common { /// @@ -13,15 +8,11 @@ public class DDDConfiguration /// /// Allow server to patch client DAT files using server's DAT files via DDDManager /// - [System.ComponentModel.DefaultValue(false)] - [JsonProperty(DefaultValueHandling = DefaultValueHandling.Populate)] - public bool EnableDATPatching { get; set; } + public bool EnableDATPatching { get; set; } = false; /// /// Upon server startup, precache all DAT files that would be sent as compressed data /// - [System.ComponentModel.DefaultValue(false)] - [JsonProperty(DefaultValueHandling = DefaultValueHandling.Populate)] - public bool PrecacheCompressedDATFiles { get; set; } + public bool PrecacheCompressedDATFiles { get; set; } = false; } } From b02b0428250082144488c8a1a2fde71caf0c2a60 Mon Sep 17 00:00:00 2001 From: Ty Conner Date: Sat, 16 Sep 2023 22:20:03 -0400 Subject: [PATCH 19/22] Update ModContainer.cs --- Source/ACE.Server/Mods/ModContainer.cs | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/Source/ACE.Server/Mods/ModContainer.cs b/Source/ACE.Server/Mods/ModContainer.cs index 984513cd67..0be93eab52 100644 --- a/Source/ACE.Server/Mods/ModContainer.cs +++ b/Source/ACE.Server/Mods/ModContainer.cs @@ -1,10 +1,11 @@ using log4net; + using McMaster.NETCore.Plugins; -using System; +using System; using System.IO; using System.Reflection; -using Newtonsoft.Json; +using System.Text.Json; namespace ACE.Server.Mods { @@ -219,7 +220,7 @@ private bool TryCreateModInstance() public void SaveMetadata() { - var json = JsonConvert.SerializeObject(Meta, Formatting.Indented); + var json = JsonSerializer.Serialize(Meta, new JsonSerializerOptions { WriteIndented = true }); var info = new FileInfo(MetadataPath); if (!info.RetryWrite(json)) From 788d295a9a606b4797480dd2f7a6c146d4f7eab2 Mon Sep 17 00:00:00 2001 From: Ty Conner Date: Sat, 16 Sep 2023 22:20:06 -0400 Subject: [PATCH 20/22] Update ModManager.cs --- Source/ACE.Server/Mods/ModManager.cs | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/Source/ACE.Server/Mods/ModManager.cs b/Source/ACE.Server/Mods/ModManager.cs index 80252f0116..fe9316de31 100644 --- a/Source/ACE.Server/Mods/ModManager.cs +++ b/Source/ACE.Server/Mods/ModManager.cs @@ -1,12 +1,15 @@ using ACE.Server.Managers; using ACE.Server.WorldObjects; + using log4net; -using Newtonsoft.Json; + using System; using System.Collections.Generic; using System.IO; using System.Linq; using System.Text; +using System.Text.Json; +using System.Text.Json.Serialization; namespace ACE.Server.Mods { @@ -141,7 +144,7 @@ private static bool TryLoadModContainer(string metadataPath, out ModContainer co try { - var metadata = JsonConvert.DeserializeObject(File.ReadAllText(metadataPath)); + var metadata = JsonSerializer.Deserialize(File.ReadAllText(metadataPath), new JsonSerializerOptions { ReadCommentHandling = JsonCommentHandling.Skip, NumberHandling = JsonNumberHandling.AllowReadingFromString }); container = new ModContainer() { From 376eaa18677a67b7a1d9491b6b9297d28a9ab371 Mon Sep 17 00:00:00 2001 From: Ty Conner Date: Sat, 16 Sep 2023 22:20:09 -0400 Subject: [PATCH 21/22] Update ModMetadata.cs --- Source/ACE.Server/Mods/ModMetadata.cs | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/Source/ACE.Server/Mods/ModMetadata.cs b/Source/ACE.Server/Mods/ModMetadata.cs index 176235b22d..fc946ff39e 100644 --- a/Source/ACE.Server/Mods/ModMetadata.cs +++ b/Source/ACE.Server/Mods/ModMetadata.cs @@ -1,5 +1,4 @@ -using Newtonsoft.Json; -using System; +using System.Text.Json.Serialization; namespace ACE.Server.Mods { @@ -11,10 +10,10 @@ public class ModMetadata public const string TYPENAME = "Mod"; public string Name { get; set; } = "SomeMod"; - public string Author { get; set; } + public string Author { get; set; } = ""; public string Description { get; set; } public string Version { get; set; } = "1.0"; - public uint Priority { get; set; } + public uint Priority { get; set; } = 1; /// /// Determines whether mod is patched on load. From 22dd74efc96e8fbe483e9ca9cb705ab57989a942 Mon Sep 17 00:00:00 2001 From: Ty Conner Date: Sat, 16 Sep 2023 22:23:15 -0400 Subject: [PATCH 22/22] Update ModMetadata.cs --- Source/ACE.Server/Mods/ModMetadata.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Source/ACE.Server/Mods/ModMetadata.cs b/Source/ACE.Server/Mods/ModMetadata.cs index fc946ff39e..4426b9bfe1 100644 --- a/Source/ACE.Server/Mods/ModMetadata.cs +++ b/Source/ACE.Server/Mods/ModMetadata.cs @@ -13,7 +13,7 @@ public class ModMetadata public string Author { get; set; } = ""; public string Description { get; set; } public string Version { get; set; } = "1.0"; - public uint Priority { get; set; } = 1; + public uint Priority { get; set; } = 0u; /// /// Determines whether mod is patched on load.