From b2d304ea94dd728aa1c39bc4764e0772967341c3 Mon Sep 17 00:00:00 2001 From: Xian55 <367101+Xian55@users.noreply.github.com> Date: Tue, 5 Dec 2023 09:56:26 +0100 Subject: [PATCH] Core: EquipmentReader: Use 'with' keyword to alter Item Utilities: Use the 'with' keyword to modify data with copy constructor --- Core/Equipments/EquipmentReader.cs | 2 +- Utilities/ReadDBC_CSV/Program.cs | 6 ++++- Utilities/ReadDBC_CSV/SpellExtractor.cs | 23 ++++++++----------- .../ReadDBC_CSV/WorldMapAreaExtractor.cs | 21 ++--------------- 4 files changed, 18 insertions(+), 34 deletions(-) diff --git a/Core/Equipments/EquipmentReader.cs b/Core/Equipments/EquipmentReader.cs index 2f3071a2..5cab41e6 100644 --- a/Core/Equipments/EquipmentReader.cs +++ b/Core/Equipments/EquipmentReader.cs @@ -45,7 +45,7 @@ public void Update(IAddonDataProvider reader) ? ItemDB.EmptyItem : itemDB.Items.TryGetValue(itemId, out Item item) ? item - : new Item() { Entry = itemId, Name = "Unknown" }; + : ItemDB.EmptyItem with { Entry = itemId, Name = "Unknown" }; OnEquipmentChanged?.Invoke(this, (index, itemId)); } diff --git a/Utilities/ReadDBC_CSV/Program.cs b/Utilities/ReadDBC_CSV/Program.cs index 0a1fdfee..6f8cf724 100644 --- a/Utilities/ReadDBC_CSV/Program.cs +++ b/Utilities/ReadDBC_CSV/Program.cs @@ -27,7 +27,11 @@ internal sealed class Program private const Locale locale = Locale.enUS; private const string path = "../../../data/"; - private const string build = "3.4.2.50375"; // SoM 1.14.3.49821 // TBCC 2.5.4.44833 // WOTLK 3.4.2.50375 + // SoM 1.14.4.51829 + // TBCC 2.5.4.44833 + // WOTLK 3.4.3.52237 + // SoD 1.15.0.52409 + private const string build = "1.15.0.52409"; public static void Main() { diff --git a/Utilities/ReadDBC_CSV/SpellExtractor.cs b/Utilities/ReadDBC_CSV/SpellExtractor.cs index c709976b..20d5d020 100644 --- a/Utilities/ReadDBC_CSV/SpellExtractor.cs +++ b/Utilities/ReadDBC_CSV/SpellExtractor.cs @@ -74,19 +74,16 @@ private static void ExtractLevels(string path, List spells) int level = row[baseLevel].Parse(); int spell = row[spellId].Parse(); - if (level > 0 && spell > 0) - { - int index = spells.FindIndex(0, x => x.Id == spell); - if (index > -1) - { - spells[index] = new Spell - { - Id = spell, - Level = level, - Name = spells[index].Name, - }; - } - } + if (level <= 0 || spell <= 0) + continue; + + bool ById(Spell x) => x.Id == spell; + int index = spells.FindIndex(0, ById); + if (index <= -1) + continue; + + Spell s = spells[index]; + spells[index] = s with { Level = level }; } } } diff --git a/Utilities/ReadDBC_CSV/WorldMapAreaExtractor.cs b/Utilities/ReadDBC_CSV/WorldMapAreaExtractor.cs index 3c4a492e..8f03951b 100644 --- a/Utilities/ReadDBC_CSV/WorldMapAreaExtractor.cs +++ b/Utilities/ReadDBC_CSV/WorldMapAreaExtractor.cs @@ -104,21 +104,16 @@ private static void ExtractBoundaries(string path, List wmas) if (index > -1) { WorldMapArea wma = wmas[index]; - wmas[index] = new WorldMapArea + wmas[index] = wma with { MapID = row[mapId].Parse(), AreaID = row[areaId].Parse(), - AreaName = wma.AreaName, - LocBottom = row[region0].Parse(), LocRight = row[region1].Parse(), LocTop = row[region3].Parse(), LocLeft = row[region4].Parse(), - - UIMapId = wma.UIMapId, - Continent = wma.Continent, }; } } @@ -145,20 +140,8 @@ private static void ExtractContinent(string path, List wmas) continue; WorldMapArea wma = wmas[i]; - wmas[i] = new WorldMapArea + wmas[i] = wma with { - MapID = wma.MapID, - AreaID = wma.AreaID, - - AreaName = wma.AreaName, - - LocBottom = wma.LocBottom, - LocRight = wma.LocRight, - - LocTop = wma.LocTop, - LocLeft = wma.LocLeft, - - UIMapId = wma.UIMapId, Continent = _directory }; }