Skip to content

Commit

Permalink
Fix indirect language row ref
Browse files Browse the repository at this point in the history
  • Loading branch information
WorkingRobot authored and NotAdam committed Oct 29, 2024
1 parent 6d2d540 commit 23dd5b7
Show file tree
Hide file tree
Showing 4 changed files with 46 additions and 2 deletions.
26 changes: 26 additions & 0 deletions src/Lumina.Tests/ExcelRows.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
using Lumina.Excel;
using Lumina.Text.ReadOnly;
using System.CodeDom.Compiler;

namespace Lumina.Tests;

Expand Down Expand Up @@ -209,4 +211,28 @@ public readonly struct Description( ExcelPage page, uint offset, uint row ) : IE

static Description IExcelRow<Description>.Create( ExcelPage page, uint offset, uint row ) =>
new( page, offset, row );
}

[Sheet( "GatheringPointBase" )]
public readonly unsafe struct GatheringPointBase( ExcelPage page, uint offset, uint row ) : IExcelRow<GatheringPointBase>
{
public uint RowId => row;

public readonly RowRef<GatheringType> GatheringType => new( page.Module, (uint)page.ReadInt32( offset ), page.Language );

static GatheringPointBase IExcelRow<GatheringPointBase>.Create( ExcelPage page, uint offset, uint row ) =>
new( page, offset, row );
}

[Sheet( "GatheringType" )]
public readonly struct GatheringType( ExcelPage page, uint offset, uint row ) : IExcelRow<GatheringType>
{
public uint RowId => row;

public readonly ReadOnlySeString Name => page.ReadString( offset, offset );
public readonly int IconMain => page.ReadInt32( offset + 4 );
public readonly int IconOff => page.ReadInt32( offset + 8 );

static GatheringType IExcelRow<GatheringType>.Create( ExcelPage page, uint offset, uint row ) =>
new( page, offset, row );
}
10 changes: 10 additions & 0 deletions src/Lumina.Tests/ExcelTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -90,4 +90,14 @@ public void RowRefIntervalTree()

Assert.Equal( brute, interval );
}

[RequiresGameInstallationFact]
public void IndirectStringSheet()
{
var gameData = RequiresGameInstallationFact.CreateGameData();

var row = gameData.GetExcelSheet<GatheringPointBase>()!.GetRow( 30 );
var name = row.GatheringType.ValueNullable?.Name;
Assert.Equal( "Harvesting", name );
}
}
6 changes: 5 additions & 1 deletion src/Lumina/Excel/RowRef{T}.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,11 @@ private ExcelSheet< T >? Sheet {
get {
if( module == null )
return null;
return _sheet ??= module.GetSheet< T >( language );
return _sheet ??= module.GetSheet< T >(
language == Data.Language.None ?
null : // Use default language if null (or fall back to None)
language
);
}
}

Expand Down
6 changes: 5 additions & 1 deletion src/Lumina/Excel/SubrowRef{T}.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,11 @@ private SubrowExcelSheet< T >? Sheet {
get {
if( module == null )
return null;
return _sheet ??= module.GetSubrowSheet< T >( language );
return _sheet ??= module.GetSubrowSheet< T >(
language == Data.Language.None ?
null : // Use default language if null (or fall back to None)
language
);
}
}

Expand Down

0 comments on commit 23dd5b7

Please sign in to comment.