Files
HellionChat/HellionChat/Sheets.cs
T
JonKazama-Hellion a651b3b9ad fix: correctness bugs flagged by CodeRabbit
Four pre-existing upstream defects fixed in v1.0.0:

- Util/GlobalParametersCache.cs GetValue captures Cache into a local
  before the bounds check, so the check and the indexed read operate
  on the same array reference even when Refresh reassigns Cache from
  the main thread between the two operations
- Util/IconUtil.cs binary search bounds: hi initialized to
  entries.Length-1 (was Length), and reset on redirect-restart;
  added entries.Length==0 short-circuit to prevent indexing into
  empty arrays
- Sheets.cs WorldsOnDatacenter compared Region.RowId, which groups
  by region instead of datacenter — now compares DataCenter.RowId
  directly so the result actually reflects same-DC worlds
- Message.cs back-reference loop iterates the processed Sender/Content
  properties rather than the raw constructor parameters, so chunks
  added or replaced by CheckMessageContent also get Message set
2026-05-03 22:03:47 +02:00

43 lines
1.9 KiB
C#

using Dalamud.Game.ClientState.Objects.SubKinds;
using Lumina.Excel;
using Lumina.Excel.Sheets;
namespace HellionChat;
public static class Sheets
{
public static readonly ExcelSheet<Item> ItemSheet;
public static readonly ExcelSheet<World> WorldSheet;
public static readonly ExcelSheet<Status> StatusSheet;
public static readonly ExcelSheet<LogKind> LogKindSheet;
public static readonly ExcelSheet<LogFilter> LogFilterSheet;
public static readonly ExcelSheet<EventItem> EventItemSheet;
public static readonly ExcelSheet<Completion> CompletionSheet;
public static readonly ExcelSheet<TerritoryType> TerritorySheet;
public static readonly ExcelSheet<TextCommand> TextCommandSheet;
public static readonly ExcelSheet<EventItemHelp> EventItemHelpSheet;
static Sheets()
{
ItemSheet = Plugin.DataManager.GetExcelSheet<Item>();
WorldSheet = Plugin.DataManager.GetExcelSheet<World>();
StatusSheet = Plugin.DataManager.GetExcelSheet<Status>();
LogKindSheet = Plugin.DataManager.GetExcelSheet<LogKind>();
LogFilterSheet = Plugin.DataManager.GetExcelSheet<LogFilter>();
EventItemSheet = Plugin.DataManager.GetExcelSheet<EventItem>();
CompletionSheet = Plugin.DataManager.GetExcelSheet<Completion>();
TerritorySheet = Plugin.DataManager.GetExcelSheet<TerritoryType>();
TextCommandSheet = Plugin.DataManager.GetExcelSheet<TextCommand>();
EventItemHelpSheet = Plugin.DataManager.GetExcelSheet<EventItemHelp>();
}
public static bool IsInForay() =>
TerritorySheet.TryGetRow(Plugin.ClientState.TerritoryType, out var row) &&
row.TerritoryIntendedUse.RowId is 41 or 61;
public static IEnumerable<World> WorldsOnDatacenter(IPlayerCharacter character)
{
var dcRow = character.HomeWorld.Value.DataCenter.RowId;
return WorldSheet.Where(world => world.IsPublic && world.DataCenter.RowId == dcRow);
}
}