Update to Lumina 5 (new Excel parsing) (#2022)

* Refactor and upgrade to new excel design

* Obsolete ExcelResolver<T> and use only RowRef<T>

* Better benchmarking for Lumina

* Add custom game-supported RSV provider

* Refactor and move Lazy<T> and nullable/cached row objects to RowRefs

* Convert IRSVProvider to delegate, resolve strings by default

* Split IExcelRow into IExcelSubrow

* Extra lumina documentation

* Minor RSV CS fixes

* Fix UIGlowPayload warning

* Fix rebase

* Update to Lumina 5
This commit is contained in:
Asriel Camora 2024-10-20 19:59:03 -07:00 committed by GitHub
parent 08d8605871
commit 0b9af0e3f4
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
49 changed files with 460 additions and 403 deletions

View file

@ -38,13 +38,6 @@ public abstract partial class Payload
/// </summary>
public bool Dirty { get; protected set; } = true;
/// <summary>
/// Gets the Lumina instance to use for any necessary data lookups.
/// </summary>
[JsonIgnore]
// TODO: We should refactor this. It should not be possible to get IDataManager through here.
protected IDataManager DataResolver => Service<DataManager>.Get();
/// <summary>
/// Decodes a binary representation of a payload into its corresponding nice object payload.
/// </summary>

View file

@ -2,7 +2,11 @@ using System.Collections.Generic;
using System.IO;
using System.Linq;
using Lumina.Excel.GeneratedSheets;
using Dalamud.Data;
using Lumina.Excel.Sheets;
using Lumina.Text.ReadOnly;
using Newtonsoft.Json;
using Serilog;
@ -106,28 +110,28 @@ public class AutoTranslatePayload : Payload, ITextProvider
this.Key = GetInteger(reader);
}
private static ReadOnlySeString ResolveTextCommand(TextCommand command)
{
// TextCommands prioritize the `Alias` field, if it not empty
// Example for this is /rangerpose2l which becomes /blackrangerposeb in chat
return !command.Alias.IsEmpty ? command.Alias : command.Command;
}
private string Resolve()
{
string value = null;
var sheet = this.DataResolver.GetExcelSheet<Completion>();
var excelModule = Service<DataManager>.Get().Excel;
var completionSheet = excelModule.GetSheet<Completion>();
Completion row = null;
try
{
// try to get the row in the Completion table itself, because this is 'easiest'
// The row may not exist at all (if the Key is for another table), or it could be the wrong row
// (again, if it's meant for another table)
row = sheet.GetRow(this.Key);
}
catch
{
} // don't care, row will be null
// try to get the row in the Completion table itself, because this is 'easiest'
// The row may not exist at all (if the Key is for another table), or it could be the wrong row
// (again, if it's meant for another table)
if (row?.Group == this.Group)
if (completionSheet.GetRowOrDefault(this.Key) is { } completion && completion.Group == this.Group)
{
// if the row exists in this table and the group matches, this is actually the correct data
value = row.Text;
value = completion.Text.ExtractText();
}
else
{
@ -135,34 +139,34 @@ public class AutoTranslatePayload : Payload, ITextProvider
{
// we need to get the linked table and do the lookup there instead
// in this case, there will only be one entry for this group id
row = sheet.First(r => r.Group == this.Group);
var row = completionSheet.First(r => r.Group == this.Group);
// many of the names contain valid id ranges after the table name, but we don't need those
var actualTableName = row.LookupTable.RawString.Split('[')[0];
var actualTableName = row.LookupTable.ExtractText().Split('[')[0];
var name = actualTableName switch
{
"Action" => this.DataResolver.GetExcelSheet<Lumina.Excel.GeneratedSheets.Action>().GetRow(this.Key).Name,
"ActionComboRoute" => this.DataResolver.GetExcelSheet<ActionComboRoute>().GetRow(this.Key).Name,
"BuddyAction" => this.DataResolver.GetExcelSheet<BuddyAction>().GetRow(this.Key).Name,
"ClassJob" => this.DataResolver.GetExcelSheet<ClassJob>().GetRow(this.Key).Name,
"Companion" => this.DataResolver.GetExcelSheet<Companion>().GetRow(this.Key).Singular,
"CraftAction" => this.DataResolver.GetExcelSheet<CraftAction>().GetRow(this.Key).Name,
"GeneralAction" => this.DataResolver.GetExcelSheet<GeneralAction>().GetRow(this.Key).Name,
"GuardianDeity" => this.DataResolver.GetExcelSheet<GuardianDeity>().GetRow(this.Key).Name,
"MainCommand" => this.DataResolver.GetExcelSheet<MainCommand>().GetRow(this.Key).Name,
"Mount" => this.DataResolver.GetExcelSheet<Mount>().GetRow(this.Key).Singular,
"Pet" => this.DataResolver.GetExcelSheet<Pet>().GetRow(this.Key).Name,
"PetAction" => this.DataResolver.GetExcelSheet<PetAction>().GetRow(this.Key).Name,
"PetMirage" => this.DataResolver.GetExcelSheet<PetMirage>().GetRow(this.Key).Name,
"PlaceName" => this.DataResolver.GetExcelSheet<PlaceName>().GetRow(this.Key).Name,
"Race" => this.DataResolver.GetExcelSheet<Race>().GetRow(this.Key).Masculine,
"TextCommand" => this.ResolveTextCommand(),
"Tribe" => this.DataResolver.GetExcelSheet<Tribe>().GetRow(this.Key).Masculine,
"Weather" => this.DataResolver.GetExcelSheet<Weather>().GetRow(this.Key).Name,
"Action" => excelModule.GetSheet<Lumina.Excel.Sheets.Action>().GetRow(this.Key).Name,
"ActionComboRoute" => excelModule.GetSheet<ActionComboRoute>().GetRow(this.Key).Name,
"BuddyAction" => excelModule.GetSheet<BuddyAction>().GetRow(this.Key).Name,
"ClassJob" => excelModule.GetSheet<ClassJob>().GetRow(this.Key).Name,
"Companion" => excelModule.GetSheet<Companion>().GetRow(this.Key).Singular,
"CraftAction" => excelModule.GetSheet<CraftAction>().GetRow(this.Key).Name,
"GeneralAction" => excelModule.GetSheet<GeneralAction>().GetRow(this.Key).Name,
"GuardianDeity" => excelModule.GetSheet<GuardianDeity>().GetRow(this.Key).Name,
"MainCommand" => excelModule.GetSheet<MainCommand>().GetRow(this.Key).Name,
"Mount" => excelModule.GetSheet<Mount>().GetRow(this.Key).Singular,
"Pet" => excelModule.GetSheet<Pet>().GetRow(this.Key).Name,
"PetAction" => excelModule.GetSheet<PetAction>().GetRow(this.Key).Name,
"PetMirage" => excelModule.GetSheet<PetMirage>().GetRow(this.Key).Name,
"PlaceName" => excelModule.GetSheet<PlaceName>().GetRow(this.Key).Name,
"Race" => excelModule.GetSheet<Race>().GetRow(this.Key).Masculine,
"TextCommand" => AutoTranslatePayload.ResolveTextCommand(excelModule.GetSheet<TextCommand>().GetRow(this.Key)),
"Tribe" => excelModule.GetSheet<Tribe>().GetRow(this.Key).Masculine,
"Weather" => excelModule.GetSheet<Weather>().GetRow(this.Key).Name,
_ => throw new Exception(actualTableName),
};
value = name;
value = name.ExtractText();
}
catch (Exception e)
{
@ -172,12 +176,4 @@ public class AutoTranslatePayload : Payload, ITextProvider
return value;
}
private Lumina.Text.SeString ResolveTextCommand()
{
// TextCommands prioritize the `Alias` field, if it not empty
// Example for this is /rangerpose2l which becomes /blackrangerposeb in chat
var result = this.DataResolver.GetExcelSheet<TextCommand>().GetRow(this.Key);
return result.Alias.Payloads.Count > 0 ? result.Alias : result.Command;
}
}

View file

@ -3,9 +3,10 @@ using System.IO;
using System.Linq;
using System.Text;
using Lumina.Excel.GeneratedSheets;
using Dalamud.Data;
using Lumina.Excel;
using Lumina.Excel.Sheets;
using Newtonsoft.Json;
using Serilog;
namespace Dalamud.Game.Text.SeStringHandling.Payloads;
@ -14,8 +15,6 @@ namespace Dalamud.Game.Text.SeStringHandling.Payloads;
/// </summary>
public class ItemPayload : Payload
{
private Item? item;
// mainly to allow overriding the name (for things like owo)
// TODO: even though this is present in some item links, it may not really have a use at all
// For things like owo, changing the text payload is probably correct, whereas changing the
@ -131,27 +130,13 @@ public class ItemPayload : Payload
public uint RawItemId => this.rawItemId;
/// <summary>
/// Gets the underlying Lumina Item represented by this payload.
/// Gets the underlying Lumina data represented by this payload. This is either a Item or EventItem <see cref="RowRef{T}"/>.
/// </summary>
/// <remarks>
/// The value is evaluated lazily and cached.
/// </remarks>
[JsonIgnore]
public Item? Item
{
get
{
// TODO(goat): This should be revamped/removed on an API level change.
if (this.Kind == ItemKind.EventItem)
{
Log.Warning("Event items cannot be fetched from the ItemPayload");
return null;
}
this.item ??= this.DataResolver.GetExcelSheet<Item>()!.GetRow(this.ItemId);
return this.item;
}
}
public RowRef Item =>
this.Kind == ItemKind.EventItem
? (RowRef)LuminaUtils.CreateRef<EventItem>(this.ItemId)
: (RowRef)LuminaUtils.CreateRef<Item>(this.ItemId);
/// <summary>
/// Gets a value indicating whether or not this item link is for a high-quality version of the item.
@ -183,7 +168,8 @@ public class ItemPayload : Payload
/// <inheritdoc/>
public override string ToString()
{
return $"{this.Type} - ItemId: {this.ItemId}, Kind: {this.Kind}, Name: {this.displayName ?? this.Item?.Name}";
var name = this.displayName ?? (this.Item.GetValueOrDefault<Item>()?.Name ?? this.Item.GetValueOrDefault<EventItem>()?.Name)?.ExtractText();
return $"{this.Type} - ItemId: {this.ItemId}, Kind: {this.Kind}, Name: {name}";
}
/// <inheritdoc/>

View file

@ -1,7 +1,10 @@
using System.Collections.Generic;
using System.IO;
using Lumina.Excel.GeneratedSheets;
using Dalamud.Data;
using Lumina.Excel;
using Lumina.Excel.Sheets;
using Newtonsoft.Json;
namespace Dalamud.Game.Text.SeStringHandling.Payloads;
@ -11,11 +14,6 @@ namespace Dalamud.Game.Text.SeStringHandling.Payloads;
/// </summary>
public class MapLinkPayload : Payload
{
private Map map;
private TerritoryType territoryType;
private string placeNameRegion;
private string placeName;
[JsonProperty]
private uint territoryTypeId;
@ -38,8 +36,8 @@ public class MapLinkPayload : Payload
// this fudge is necessary basically to ensure we don't shift down a full tenth
// because essentially values are truncated instead of rounded, so 3.09999f will become
// 3.0f and not 3.1f
this.RawX = this.ConvertMapCoordinateToRawPosition(niceXCoord + fudgeFactor, this.Map.SizeFactor, this.Map.OffsetX);
this.RawY = this.ConvertMapCoordinateToRawPosition(niceYCoord + fudgeFactor, this.Map.SizeFactor, this.Map.OffsetY);
this.RawX = this.ConvertMapCoordinateToRawPosition(niceXCoord + fudgeFactor, this.Map.Value.SizeFactor, this.Map.Value.OffsetX);
this.RawY = this.ConvertMapCoordinateToRawPosition(niceYCoord + fudgeFactor, this.Map.Value.SizeFactor, this.Map.Value.OffsetY);
}
/// <summary>
@ -72,20 +70,14 @@ public class MapLinkPayload : Payload
/// <summary>
/// Gets the Map specified for this map link.
/// </summary>
/// <remarks>
/// The value is evaluated lazily and cached.
/// </remarks>
[JsonIgnore]
public Map Map => this.map ??= this.DataResolver.GetExcelSheet<Map>().GetRow(this.mapId);
public RowRef<Map> Map => LuminaUtils.CreateRef<Map>(this.mapId);
/// <summary>
/// Gets the TerritoryType specified for this map link.
/// </summary>
/// <remarks>
/// The value is evaluated lazily and cached.
/// </remarks>
[JsonIgnore]
public TerritoryType TerritoryType => this.territoryType ??= this.DataResolver.GetExcelSheet<TerritoryType>().GetRow(this.territoryTypeId);
public RowRef<TerritoryType> TerritoryType => LuminaUtils.CreateRef<TerritoryType>(this.territoryTypeId);
/// <summary>
/// Gets the internal x-coordinate for this map position.
@ -102,13 +94,13 @@ public class MapLinkPayload : Payload
/// <summary>
/// Gets the readable x-coordinate position for this map link. This value is approximate and unrounded.
/// </summary>
public float XCoord => this.ConvertRawPositionToMapCoordinate(this.RawX, this.Map.SizeFactor, this.Map.OffsetX);
public float XCoord => this.ConvertRawPositionToMapCoordinate(this.RawX, this.Map.Value.SizeFactor, this.Map.Value.OffsetX);
/// <summary>
/// Gets the readable y-coordinate position for this map link. This value is approximate and unrounded.
/// </summary>
[JsonIgnore]
public float YCoord => this.ConvertRawPositionToMapCoordinate(this.RawY, this.Map.SizeFactor, this.Map.OffsetY);
public float YCoord => this.ConvertRawPositionToMapCoordinate(this.RawY, this.Map.Value.SizeFactor, this.Map.Value.OffsetY);
// there is no Z; it's purely in the text payload where applicable
@ -143,18 +135,18 @@ public class MapLinkPayload : Payload
/// Gets the region name for this map link. This corresponds to the upper zone name found in the actual in-game map UI. eg, "La Noscea".
/// </summary>
[JsonIgnore]
public string PlaceNameRegion => this.placeNameRegion ??= this.TerritoryType.PlaceNameRegion.Value?.Name;
public string PlaceNameRegion => this.TerritoryType.Value.PlaceNameRegion.Value.Name.ExtractText();
/// <summary>
/// Gets the place name for this map link. This corresponds to the lower zone name found in the actual in-game map UI. eg, "Limsa Lominsa Upper Decks".
/// </summary>
[JsonIgnore]
public string PlaceName => this.placeName ??= this.TerritoryType.PlaceName.Value?.Name;
public string PlaceName => this.TerritoryType.Value.PlaceName.Value.Name.ExtractText();
/// <summary>
/// Gets the data string for this map link, for use by internal game functions that take a string variant and not a binary payload.
/// </summary>
public string DataString => $"m:{this.TerritoryType.RowId},{this.Map.RowId},{this.RawX},{this.RawY}";
public string DataString => $"m:{this.territoryTypeId},{this.mapId},{this.RawX},{this.RawY}";
/// <inheritdoc/>
public override string ToString()

View file

@ -2,7 +2,10 @@ using System.Collections.Generic;
using System.IO;
using System.Text;
using Lumina.Excel.GeneratedSheets;
using Dalamud.Data;
using Lumina.Excel;
using Lumina.Excel.Sheets;
using Newtonsoft.Json;
namespace Dalamud.Game.Text.SeStringHandling.Payloads;
@ -12,8 +15,6 @@ namespace Dalamud.Game.Text.SeStringHandling.Payloads;
/// </summary>
public class PlayerPayload : Payload
{
private World world;
[JsonProperty]
private uint serverId;
@ -43,11 +44,8 @@ public class PlayerPayload : Payload
/// <summary>
/// Gets the Lumina object representing the player's home server.
/// </summary>
/// <remarks>
/// Value is evaluated lazily and cached.
/// </remarks>
[JsonIgnore]
public World World => this.world ??= this.DataResolver.GetExcelSheet<World>().GetRow(this.serverId);
public RowRef<World> World => LuminaUtils.CreateRef<World>(this.serverId);
/// <summary>
/// Gets or sets the player's displayed name. This does not contain the server name.
@ -72,7 +70,7 @@ public class PlayerPayload : Payload
/// The world name will always be present.
/// </summary>
[JsonIgnore]
public string DisplayedName => $"{this.PlayerName}{(char)SeIconChar.CrossWorld}{this.World.Name}";
public string DisplayedName => $"{this.PlayerName}{(char)SeIconChar.CrossWorld}{this.World.ValueNullable?.Name}";
/// <inheritdoc/>
public override PayloadType Type => PayloadType.Player;
@ -80,7 +78,7 @@ public class PlayerPayload : Payload
/// <inheritdoc/>
public override string ToString()
{
return $"{this.Type} - PlayerName: {this.PlayerName}, ServerId: {this.serverId}, ServerName: {this.World.Name}";
return $"{this.Type} - PlayerName: {this.PlayerName}, ServerId: {this.serverId}, ServerName: {this.World.ValueNullable?.Name}";
}
/// <inheritdoc/>

View file

@ -1,7 +1,10 @@
using System.Collections.Generic;
using System.IO;
using Lumina.Excel.GeneratedSheets;
using Dalamud.Data;
using Lumina.Excel;
using Lumina.Excel.Sheets;
using Newtonsoft.Json;
namespace Dalamud.Game.Text.SeStringHandling.Payloads;
@ -11,8 +14,6 @@ namespace Dalamud.Game.Text.SeStringHandling.Payloads;
/// </summary>
public class QuestPayload : Payload
{
private Quest quest;
[JsonProperty]
private uint questId;
@ -40,16 +41,13 @@ public class QuestPayload : Payload
/// <summary>
/// Gets the underlying Lumina Quest represented by this payload.
/// </summary>
/// <remarks>
/// The value is evaluated lazily and cached.
/// </remarks>
[JsonIgnore]
public Quest Quest => this.quest ??= this.DataResolver.GetExcelSheet<Quest>().GetRow(this.questId);
public RowRef<Quest> Quest => LuminaUtils.CreateRef<Quest>(this.questId);
/// <inheritdoc />
public override string ToString()
{
return $"{this.Type} - QuestId: {this.questId}, Name: {this.Quest?.Name ?? "QUEST NOT FOUND"}";
return $"{this.Type} - QuestId: {this.questId}, Name: {this.Quest.ValueNullable?.Name.ExtractText() ?? "QUEST NOT FOUND"}";
}
/// <inheritdoc/>

View file

@ -1,7 +1,10 @@
using System.Collections.Generic;
using System.IO;
using Lumina.Excel.GeneratedSheets;
using Dalamud.Data;
using Lumina.Excel;
using Lumina.Excel.Sheets;
using Newtonsoft.Json;
namespace Dalamud.Game.Text.SeStringHandling.Payloads;
@ -11,8 +14,6 @@ namespace Dalamud.Game.Text.SeStringHandling.Payloads;
/// </summary>
public class StatusPayload : Payload
{
private Status status;
[JsonProperty]
private uint statusId;
@ -40,16 +41,13 @@ public class StatusPayload : Payload
/// <summary>
/// Gets the Lumina Status object represented by this payload.
/// </summary>
/// <remarks>
/// The value is evaluated lazily and cached.
/// </remarks>
[JsonIgnore]
public Status Status => this.status ??= this.DataResolver.GetExcelSheet<Status>().GetRow(this.statusId);
public RowRef<Status> Status => LuminaUtils.CreateRef<Status>(this.statusId);
/// <inheritdoc/>
public override string ToString()
{
return $"{this.Type} - StatusId: {this.statusId}, Name: {this.Status.Name}";
return $"{this.Type} - StatusId: {this.statusId}, Name: {this.Status.ValueNullable?.Name}";
}
/// <inheritdoc/>

View file

@ -1,7 +1,10 @@
using System.Collections.Generic;
using System.IO;
using Lumina.Excel.GeneratedSheets;
using Dalamud.Data;
using Lumina.Excel;
using Lumina.Excel.Sheets;
using Newtonsoft.Json;
namespace Dalamud.Game.Text.SeStringHandling.Payloads;
@ -11,8 +14,6 @@ namespace Dalamud.Game.Text.SeStringHandling.Payloads;
/// </summary>
public class UIForegroundPayload : Payload
{
private UIColor color;
[JsonProperty]
private ushort colorKey;
@ -51,11 +52,8 @@ public class UIForegroundPayload : Payload
/// <summary>
/// Gets a Lumina UIColor object representing this payload. The actual color data is at UIColor.UIForeground.
/// </summary>
/// <remarks>
/// The value is evaluated lazily and cached.
/// </remarks>
[JsonIgnore]
public UIColor UIColor => this.color ??= this.DataResolver.GetExcelSheet<UIColor>().GetRow(this.colorKey);
public RowRef<UIColor> UIColor => LuminaUtils.CreateRef<UIColor>(this.colorKey);
/// <summary>
/// Gets or sets the color key used as a lookup in the UIColor table for this foreground color.
@ -63,15 +61,11 @@ public class UIForegroundPayload : Payload
[JsonIgnore]
public ushort ColorKey
{
get
{
return this.colorKey;
}
get => this.colorKey;
set
{
this.colorKey = value;
this.color = null;
this.Dirty = true;
}
}
@ -80,13 +74,13 @@ public class UIForegroundPayload : Payload
/// Gets the Red/Green/Blue/Alpha values for this foreground color, encoded as a typical hex color.
/// </summary>
[JsonIgnore]
public uint RGBA => this.UIColor.UIForeground;
public uint RGBA => this.UIColor.Value.UIForeground;
/// <summary>
/// Gets the ABGR value for this foreground color, as ImGui requires it in PushColor.
/// </summary>
[JsonIgnore]
public uint ABGR => Interface.ColorHelpers.SwapEndianness(this.UIColor.UIForeground);
public uint ABGR => Interface.ColorHelpers.SwapEndianness(this.UIColor.Value.UIForeground);
/// <inheritdoc/>
public override string ToString()

View file

@ -1,7 +1,10 @@
using System.Collections.Generic;
using System.IO;
using Lumina.Excel.GeneratedSheets;
using Dalamud.Data;
using Lumina.Excel;
using Lumina.Excel.Sheets;
using Newtonsoft.Json;
namespace Dalamud.Game.Text.SeStringHandling.Payloads;
@ -11,8 +14,6 @@ namespace Dalamud.Game.Text.SeStringHandling.Payloads;
/// </summary>
public class UIGlowPayload : Payload
{
private UIColor color;
[JsonProperty]
private ushort colorKey;
@ -57,7 +58,6 @@ public class UIGlowPayload : Payload
set
{
this.colorKey = value;
this.color = null;
this.Dirty = true;
}
}
@ -71,22 +71,19 @@ public class UIGlowPayload : Payload
/// Gets the Red/Green/Blue/Alpha values for this glow color, encoded as a typical hex color.
/// </summary>
[JsonIgnore]
public uint RGBA => this.UIColor.UIGlow;
public uint RGBA => this.UIColor.Value.UIGlow;
/// <summary>
/// Gets the ABGR value for this glow color, as ImGui requires it in PushColor.
/// </summary>
[JsonIgnore]
public uint ABGR => Interface.ColorHelpers.SwapEndianness(this.UIColor.UIGlow);
public uint ABGR => Interface.ColorHelpers.SwapEndianness(this.UIColor.Value.UIGlow);
/// <summary>
/// Gets a Lumina UIColor object representing this payload. The actual color data is at UIColor.UIGlow.
/// </summary>
/// <remarks>
/// The value is evaluated lazily and cached.
/// </remarks>
[JsonIgnore]
public UIColor UIColor => this.color ??= this.DataResolver.GetExcelSheet<UIColor>().GetRow(this.colorKey);
public RowRef<UIColor> UIColor => LuminaUtils.CreateRef<UIColor>(this.colorKey);
/// <inheritdoc/>
public override string ToString()

View file

@ -7,7 +7,7 @@ using System.Text;
using Dalamud.Data;
using Dalamud.Game.Text.SeStringHandling.Payloads;
using Dalamud.Utility;
using Lumina.Excel.GeneratedSheets;
using Lumina.Excel.Sheets;
using Newtonsoft.Json;
namespace Dalamud.Game.Text.SeStringHandling;
@ -200,12 +200,12 @@ public class SeString
case ItemPayload.ItemKind.Normal:
case ItemPayload.ItemKind.Collectible:
case ItemPayload.ItemKind.Hq:
var item = data.GetExcelSheet<Item>()?.GetRow(itemId);
displayName = item?.Name;
var item = data.GetExcelSheet<Item>()?.GetRowOrDefault(itemId);
displayName = item?.Name.ExtractText();
rarity = item?.Rarity ?? 1;
break;
case ItemPayload.ItemKind.EventItem:
displayName = data.GetExcelSheet<EventItem>()?.GetRow(itemId)?.Name;
displayName = data.GetExcelSheet<EventItem>()?.GetRowOrDefault(itemId)?.Name.ExtractText();
break;
default:
throw new ArgumentOutOfRangeException(nameof(kind), kind, null);
@ -251,7 +251,7 @@ public class SeString
/// <returns>An SeString containing all the payloads necessary to display an item link in the chat log.</returns>
public static SeString CreateItemLink(Item item, bool isHq, string? displayNameOverride = null)
{
return CreateItemLink(item.RowId, isHq, displayNameOverride ?? item.Name);
return CreateItemLink(item.RowId, isHq, displayNameOverride ?? item.Name.ExtractText());
}
/// <summary>
@ -360,15 +360,14 @@ public class SeString
var mapSheet = data.GetExcelSheet<Map>();
var matches = data.GetExcelSheet<PlaceName>()
.Where(row => row.Name.ToString().ToLowerInvariant() == placeName.ToLowerInvariant())
.ToArray();
.Where(row => row.Name.ExtractText().Equals(placeName, StringComparison.InvariantCultureIgnoreCase));
foreach (var place in matches)
{
var map = mapSheet.FirstOrDefault(row => row.PlaceName.Row == place.RowId);
if (map != null && map.TerritoryType.Row != 0)
var map = mapSheet.Cast<Map?>().FirstOrDefault(row => row!.Value.PlaceName.RowId == place.RowId);
if (map.HasValue && map.Value.TerritoryType.RowId != 0)
{
return CreateMapLinkWithInstance(map.TerritoryType.Row, map.RowId, instance, xCoord, yCoord, fudgeFactor);
return CreateMapLinkWithInstance(map.Value.TerritoryType.RowId, map.Value.RowId, instance, xCoord, yCoord, fudgeFactor);
}
}