Skip to content

Commit

Permalink
Core: EquipmentReader: Use 'with' keyword to alter Item
Browse files Browse the repository at this point in the history
Utilities: Use the 'with' keyword to modify data with copy constructor
  • Loading branch information
Xian55 committed Dec 5, 2023
1 parent 2f007fa commit b2d304e
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 34 deletions.
2 changes: 1 addition & 1 deletion Core/Equipments/EquipmentReader.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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));
}
Expand Down
6 changes: 5 additions & 1 deletion Utilities/ReadDBC_CSV/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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()
{
Expand Down
23 changes: 10 additions & 13 deletions Utilities/ReadDBC_CSV/SpellExtractor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -74,19 +74,16 @@ private static void ExtractLevels(string path, List<Spell> spells)
int level = row[baseLevel].Parse<int>();
int spell = row[spellId].Parse<int>();

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 };
}
}
}
21 changes: 2 additions & 19 deletions Utilities/ReadDBC_CSV/WorldMapAreaExtractor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -104,21 +104,16 @@ private static void ExtractBoundaries(string path, List<WorldMapArea> wmas)
if (index > -1)
{
WorldMapArea wma = wmas[index];
wmas[index] = new WorldMapArea
wmas[index] = wma with
{
MapID = row[mapId].Parse<int>(),
AreaID = row[areaId].Parse<int>(),

AreaName = wma.AreaName,

LocBottom = row[region0].Parse<float>(),
LocRight = row[region1].Parse<float>(),

LocTop = row[region3].Parse<float>(),
LocLeft = row[region4].Parse<float>(),

UIMapId = wma.UIMapId,
Continent = wma.Continent,
};
}
}
Expand All @@ -145,20 +140,8 @@ private static void ExtractContinent(string path, List<WorldMapArea> 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
};
}
Expand Down

0 comments on commit b2d304e

Please sign in to comment.