More fixes, some cleanup.

This commit is contained in:
Ottermandias 2022-03-17 14:03:57 +01:00
parent 581b91b337
commit e6752ade04
20 changed files with 193 additions and 361 deletions

View file

@ -121,7 +121,7 @@ public sealed unsafe class ExpandedEqdpFile : MetaBaseFile
public static EqdpEntry GetDefault( int fileIdx, int setIdx )
{
var data = ( byte* )Penumbra.CharacterUtility.DefaultResources[ fileIdx ].Address;
var data = ( byte* )Penumbra.CharacterUtility.DefaultResource( fileIdx ).Address;
var blockSize = *( ushort* )( data + IdentifierSize );
var totalBlockCount = *( ushort* )( data + IdentifierSize + 2 );
@ -139,7 +139,7 @@ public sealed unsafe class ExpandedEqdpFile : MetaBaseFile
var blockData = ( ushort* )( data + IdentifierSize + PreambleSize + totalBlockCount * 2 + block * 2 );
var x = new ReadOnlySpan< ushort >( blockData, blockSize );
return (EqdpEntry) (*( blockData + setIdx % blockSize ));
return ( EqdpEntry )( *( blockData + setIdx % blockSize ) );
}
public static EqdpEntry GetDefault( GenderRace raceCode, bool accessory, int setIdx )

View file

@ -201,7 +201,9 @@ public unsafe class ImcFile : MetaBaseFile
var file = Dalamud.GameData.GetFile( path.ToString() );
if( file == null )
{
throw new Exception();
throw new Exception(
"Could not obtain default Imc File.\n"
+ "Either the default file does not exist (possibly for offhand files from TexTools) or the installation is corrupted." );
}
fixed( byte* ptr = file.Data )

View file

@ -24,8 +24,10 @@ public unsafe class MetaBaseFile : IDisposable
{
Length = length;
Data = ( byte* )MemoryHelper.GameAllocateDefault( ( ulong )length );
;
GC.AddMemoryPressure( length );
if( length > 0 )
{
GC.AddMemoryPressure( length );
}
}
// Free memory.
@ -33,7 +35,11 @@ public unsafe class MetaBaseFile : IDisposable
{
var ptr = ( IntPtr )Data;
MemoryHelper.GameFree( ref ptr, ( ulong )Length );
GC.RemoveMemoryPressure( Length );
if( Length > 0 )
{
GC.RemoveMemoryPressure( Length );
}
Length = 0;
Data = null;
}