Skip to content

Commit

Permalink
Merge pull request #74 from lmcintyre/exdschema_support
Browse files Browse the repository at this point in the history
Fix GetPageForRow
  • Loading branch information
NotAdam authored Oct 22, 2023
2 parents 48c15e2 + dcdb077 commit 6852fa1
Showing 1 changed file with 5 additions and 8 deletions.
13 changes: 5 additions & 8 deletions src/Lumina/Excel/LazyRow.cs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ public interface ILazyRow

public class EmptyLazyRow : ILazyRow
{
private static readonly Dictionary< string, List<Range> > _ranges = new();
private static readonly Dictionary< string, HashSet<uint> > _ranges = new();

public uint Row { get; set; }
public bool IsValueCreated => false;
Expand All @@ -52,20 +52,17 @@ public static ILazyRow GetFirstLazyRowOrEmpty( GameData gameData, uint row, Lang
{
if( !_ranges.ContainsKey( sheetName ) )
{
var exh = gameData.GetFile< ExcelHeaderFile >( $"exd/{sheetName}.exh" );
var exh = gameData.Excel.GetSheetRaw( sheetName );
if( exh == null )
{
continue;
}
_ranges.Add( sheetName, exh.DataPages.Select( p => new Range( (int)p.StartId, (int) (p.StartId + p.RowCount) ) ).ToList() );
_ranges.Add( sheetName, exh.DataPages.SelectMany(p => p.RowData.Keys).ToHashSet() );
}

foreach( var range in _ranges[sheetName] )
if( _ranges[ sheetName ].Contains( row ) )
{
if (row >= range.Start.Value && row < range.End.Value)
{
return new LazyRow< ExcelRow >( gameData, row, language );
}
return new LazyRow< ExcelRow >( gameData, row, language );
}
}
return new EmptyLazyRow( row );
Expand Down

0 comments on commit 6852fa1

Please sign in to comment.