Skip to content

Commit

Permalink
3e6 fix
Browse files Browse the repository at this point in the history
  • Loading branch information
slotthhy committed Jan 14, 2021
1 parent 77cda60 commit c55e095
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions Penumbra/Importer/TexToolsImport.cs
Original file line number Diff line number Diff line change
Expand Up @@ -267,6 +267,9 @@ private void ExtractMod( DirectoryInfo outDirectory, SimpleMod mod, SqPackStream
var extractedFile = new FileInfo( Path.Combine( outDirectory.FullName, mod.FullPath ) );
extractedFile.Directory?.Create();

if( extractedFile.FullName.EndsWith( "mdl" ) )
ProcessMdl( data.Data );

File.WriteAllBytes( extractedFile.FullName, data.Data );
}
catch( Exception ex )
Expand All @@ -275,6 +278,21 @@ private void ExtractMod( DirectoryInfo outDirectory, SimpleMod mod, SqPackStream
}
}

private void ProcessMdl( byte[] mdl )
{
// Model file header LOD num
mdl[ 64 ] = 1;

// Model header LOD num
var stackSize = BitConverter.ToUInt32( mdl, 4 );
var runtimeBegin = stackSize + 0x44;
var stringsLengthOffset = runtimeBegin + 4;
var stringsLength = BitConverter.ToUInt32( mdl, (int) stringsLengthOffset );
var modelHeaderStart = stringsLengthOffset + stringsLength + 4;
var modelHeaderLodOffset = 22;
mdl[ modelHeaderStart + modelHeaderLodOffset ] = 1;
}

private static Stream GetStreamFromZipEntry( ZipFile file, ZipEntry entry )
{
return file.GetInputStream( entry );
Expand Down

0 comments on commit c55e095

Please sign in to comment.