Skip to content

Commit

Permalink
Fix compiler errors
Browse files Browse the repository at this point in the history
  • Loading branch information
WorkingRobot committed Sep 29, 2024
1 parent 9088fe3 commit 2ce372a
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 19 deletions.
6 changes: 3 additions & 3 deletions src/Lumina.Tests/RequiresGameInstallationFact.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,17 @@ namespace Lumina.Tests;

public sealed class RequiresGameInstallationFact : FactAttribute
{
private const string path = @"C:\Program Files (x86)\SquareEnix\FINAL FANTASY XIV - A Realm Reborn\game\sqpack";
private const string Path = @"C:\Program Files (x86)\SquareEnix\FINAL FANTASY XIV - A Realm Reborn\game\sqpack";

public RequiresGameInstallationFact()
{
if( !Directory.Exists( path ) )
if( !Directory.Exists( Path ) )
Skip = "Game installation is not found at the default path.";
}

public static GameData CreateGameData()
{
return new( path, new()
return new( Path, new()
{
PanicOnSheetChecksumMismatch = false,
} );
Expand Down
40 changes: 25 additions & 15 deletions src/Lumina.Tests/SeStringBuilderTests.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Text;
using Lumina.Data;
Expand Down Expand Up @@ -311,7 +312,7 @@ static Addon IExcelRow<Addon>.Create( ExcelPage page, uint offset, uint row ) =>
[RequiresGameInstallationFact]
public void AddonIsParsedCorrectly()
{
var gameData = new GameData( @"C:\Program Files (x86)\SquareEnix\FINAL FANTASY XIV - A Realm Reborn\game\sqpack" );
var gameData = RequiresGameInstallationFact.CreateGameData();
var addon = gameData.Excel.GetSheet< Addon >();
var ssb = new SeStringBuilder();
var expected = new Dictionary< uint, ReadOnlySeString >
Expand Down Expand Up @@ -438,7 +439,7 @@ public void AddonIsParsedCorrectly()
{
_outputHelper.WriteLine( $"{row.RowId}\t{row.Text.ExtractText()}\t{row.Text}" );
if( expected.TryGetValue( row.RowId, out var expectedSeString ) )
Assert.StrictEqual( expectedSeString, r );
Assert.StrictEqual( expectedSeString, row.Text );
}
}

Expand Down Expand Up @@ -589,28 +590,25 @@ public void FriendlyErrorMessage()
[RequiresGameInstallationFact]
public void AllSheetsTextColumnCodec()
{
var gameData = new GameData( @"C:\Program Files (x86)\SquareEnix\FINAL FANTASY XIV - A Realm Reborn\game\sqpack" );
var gameData = RequiresGameInstallationFact.CreateGameData();
var ssb = new SeStringBuilder();
foreach( var sheetName in gameData.Excel.GetSheetNames() )
foreach( var sheetName in gameData.Excel.SheetNames )
{
var languages = gameData.GetFile< ExcelHeaderFile >( ExcelModule.BuildExcelHeaderPath( sheetName ) )?.Languages ?? [Language.None];
var header = gameData.GetFile<ExcelHeaderFile>( $"exd/{sheetName}.exh" );
if( header?.Header.Variant == ExcelVariant.Subrows )
continue;
var languages = header?.Languages ?? [Language.None];
foreach( var language in languages )
{
if( gameData.Excel.GetSheetRaw( sheetName, language ) is not { } sheet )
continue;

// CustomTalkDefineClient: it currently fails at reading string columns in sheets of subrow variant.
if( sheet.Variant != ExcelVariant.Default )
if( gameData.Excel.GetSheet<RawRow>( language, sheetName ) is not { } sheet )
continue;

var stringColumns = sheet.Columns.Where( c => c.Type == ExcelColumnDataType.String ).Select( c => c.Offset ).ToArray();
foreach( var row in sheet )
{
for( var i = 0; i < sheet.Columns.Length; i++ )
foreach( var columnOffset in stringColumns )
{
if( sheet.Columns[ i ].Type != ExcelColumnDataType.String )
continue;

var test1 = row.ReadColumn< SeString >( i ).AsReadOnly();
var test1 = row.ReadString(columnOffset);
if( test1.Data.Span.IndexOf( "payload:"u8 ) != -1 )
throw new( $"Unsupported payload at {sheetName}#{row.RowId}; {test1}" );

Expand All @@ -630,4 +628,16 @@ public void AllSheetsTextColumnCodec()
}
}
}

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

public ReadOnlySeString ReadString( ushort off ) =>
page.ReadString( off + offset, offset );

static RawRow IExcelRow<RawRow>.Create( ExcelPage page, uint offset, uint row ) =>
new( page, offset, row );
}
}
2 changes: 1 addition & 1 deletion src/Lumina/Excel/ExcelModule.cs
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ public ExcelModule( GameData gameData )
GameData.Logger?.Information( "got {ExltEntryCount} exlt entries", files.ExdMap.Count );

DefinedSheetCache = files.ExdMap.Keys
.Select( name => ( Name: name, Header: GameData.GetFile< ExcelHeaderFile >( $"exd/{name}.exh") ) )
.Select( name => ( Name: name, Header: GameData.GetFile< ExcelHeaderFile >( $"exd/{name}.exh" ) ) )
.Where( sheet => sheet.Header is not null )
.ToFrozenDictionary(
sheet => sheet.Name,
Expand Down

0 comments on commit 2ce372a

Please sign in to comment.