Skip to content

Commit

Permalink
fix formatting & build error
Browse files Browse the repository at this point in the history
  • Loading branch information
NotAdam committed May 16, 2021
1 parent f723d45 commit ef1f193
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 33 deletions.
4 changes: 2 additions & 2 deletions src/Lumina.Excel/GeneratedSheets/ScenarioTreeTips.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ public class ScenarioTreeTips : ExcelRow
{

public byte Unknown0 { get; set; }
public LazyRow< ScenarioTreeTipsQuest > Tips1 { get; set; }
public uint Tips1 { get; set; }
public ushort Unknown2 { get; set; }
public LazyRow< ScenarioTree > Tips2 { get; set; }

Expand All @@ -20,7 +20,7 @@ public override void PopulateData( RowParser parser, GameData gameData, Language
base.PopulateData( parser, gameData, language );

Unknown0 = parser.ReadColumn< byte >( 0 );
Tips1 = new LazyRow< ScenarioTreeTipsQuest >( gameData, parser.ReadColumn< uint >( 1 ), language );
Tips1 = parser.ReadColumn< uint >( 1 );
Unknown2 = parser.ReadColumn< ushort >( 2 );
Tips2 = new LazyRow< ScenarioTree >( gameData, parser.ReadColumn< uint >( 3 ), language );
}
Expand Down
14 changes: 8 additions & 6 deletions src/Lumina/Data/Files/Pcb/PcbListFile.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,11 @@ namespace Lumina.Data.Files.Pcb
[FileExtension( "list.pcb" )]
public class PcbListFile : FileResource
{
public struct PcbNodeList {
public struct PcbNodeList
{
public Common.BoundingBox BoundingBox;
public ListNode[] Children;

public static PcbNodeList Read( BinaryReader reader )
{
var nodeList = new PcbNodeList
Expand All @@ -22,7 +23,7 @@ public static PcbNodeList Read( BinaryReader reader )

// Padding
reader.BaseStream.Position += 4;

for( var i = 0; i < nodeList.Children.Length; i++ )
{
nodeList.Children[ i ] = ListNode.Read( reader );
Expand All @@ -31,7 +32,7 @@ public static PcbNodeList Read( BinaryReader reader )
return nodeList;
}
}

public struct ListNode
{
public uint Id;
Expand Down Expand Up @@ -60,10 +61,11 @@ public override void LoadFile()
var isList = Reader.ReadUInt32() != 0;
Reader.BaseStream.Position = streamStart;

if( !isList ) {
if( !isList )
{
throw new InvalidOperationException( "Error parsing pcb list" );
}

Nodes = PcbNodeList.Read( Reader );
}
}
Expand Down
51 changes: 26 additions & 25 deletions src/Lumina/Data/Files/Pcb/PcbResourceFile.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,15 @@ namespace Lumina.Data.Files.Pcb
[FileExtension( ".pcb" )]
public class PcbResourceFile : FileResource
{
public struct PcbResourceHeader {
public struct PcbResourceHeader
{
public uint Magic;
public uint Version;
public uint TotalNodes;
public uint TotalPolygons;

public List<ResourceNode> Children;
public List< ResourceNode > Children;

public static PcbResourceHeader Read( BinaryReader reader )
{
var header = new PcbResourceHeader
Expand All @@ -31,20 +32,20 @@ public static PcbResourceHeader Read( BinaryReader reader )

if( header.TotalNodes == 0 )
return header;
header.Children = new List<ResourceNode>();

header.Children = new List< ResourceNode >();

var totalNodesRead = 0;
while( totalNodesRead <= header.TotalNodes )
{
header.Children.Add( ResourceNode.ReadWithCount( reader, out var nodesRead ) );
totalNodesRead += nodesRead;
}

return header;
}
}

public struct ResourceNode
{
public uint Magic;
Expand All @@ -56,14 +57,14 @@ public struct ResourceNode
public Common.Vector3[] Vertices;
public Polygon[] Polygons;

public List<ResourceNode> Children;
public List< ResourceNode > Children;

public static ResourceNode ReadWithCount( BinaryReader reader, out int totalNodesRead )
{
totalNodesRead = 1;

var initialPosition = reader.BaseStream.Position;

var header = new ResourceNode
{
Magic = reader.ReadUInt32(),
Expand All @@ -75,16 +76,16 @@ public static ResourceNode ReadWithCount( BinaryReader reader, out int totalNode
var numVertFloat16 = reader.ReadUInt16();
header.Polygons = new Polygon[reader.ReadUInt16()];
var numVertFloat32 = reader.ReadUInt16();

header.Vertices = new Common.Vector3[numVertFloat16 + numVertFloat32];

// Padding
reader.BaseStream.Position += 2;


if( header.GroupLength != 0 )
{
header.Children = new List<ResourceNode>();
header.Children = new List< ResourceNode >();

var finalPosition = initialPosition + header.GroupLength;
while( reader.BaseStream.Position + header.HeaderSkip < finalPosition )
Expand All @@ -100,27 +101,27 @@ public static ResourceNode ReadWithCount( BinaryReader reader, out int totalNode
{
header.Vertices[ i ] = Common.Vector3.Read( reader );
}

for( var i = numVertFloat32; i < numVertFloat32 + numVertFloat16; i++ )
{
header.Vertices[ i ] = Common.Vector3.Read16( reader );
}

for( var i = 0; i < header.Polygons.Length; i++ )
{
header.Polygons[i] = Polygon.Read( reader );
header.Polygons[ i ] = Polygon.Read( reader );
}


return header;
}
}

public struct Polygon
{
public byte[] VertexIndex;
public ushort Unknown;

public static Polygon Read( BinaryReader reader )
{
var polygon = new Polygon
Expand Down Expand Up @@ -158,9 +159,9 @@ public override void LoadFile()

public override string ToString()
{
var sb = new StringBuilder($"Total Nodes: {Nodes.TotalNodes}; Total Polygons: {Nodes.TotalPolygons}.");
foreach (var n in Nodes.Children)
var sb = new StringBuilder( $"Total Nodes: {Nodes.TotalNodes}; Total Polygons: {Nodes.TotalPolygons}." );

foreach( var n in Nodes.Children )
{
Stringify( sb, n, "" );
}
Expand All @@ -173,7 +174,7 @@ private static void Stringify( StringBuilder sb, ResourceNode r, string tabs )
sb.AppendLine( $"{tabs}Bounding Box: " +
$"({r.BoundingBox.Min.X}, {r.BoundingBox.Min.Y}, {r.BoundingBox.Min.Z}) => " +
$"({r.BoundingBox.Max.X}, {r.BoundingBox.Max.Y}, {r.BoundingBox.Max.Z})" );

if( r.Polygons.Length > 0 )
{
sb.AppendLine( $"{tabs}Polygons:" );
Expand All @@ -189,7 +190,7 @@ private static void Stringify( StringBuilder sb, ResourceNode r, string tabs )
}

if( !( r.Children?.Count > 0 ) ) return;

sb.AppendLine( $"{tabs}Children:" );
foreach( var c in r.Children )
{
Expand Down

0 comments on commit ef1f193

Please sign in to comment.