mirror of
https://github.com/xivdev/Penumbra.git
synced 2026-02-21 07:17:53 +01:00
Rework some metastuff.
This commit is contained in:
parent
53818f3556
commit
f0b970c102
25 changed files with 312 additions and 221 deletions
|
|
@ -11,6 +11,9 @@ namespace Penumbra.Meta.Files;
|
|||
// We only support manipulating the racial scaling parameters at the moment.
|
||||
public sealed unsafe class CmpFile : MetaBaseFile
|
||||
{
|
||||
public static readonly Interop.CharacterUtility.InternalIndex InternalIndex =
|
||||
Interop.CharacterUtility.ReverseIndices[ ( int )CharacterUtility.Index.HumanCmp ];
|
||||
|
||||
private const int RacialScalingStart = 0x2A800;
|
||||
|
||||
public float this[ SubRace subRace, RspAttribute attribute ]
|
||||
|
|
@ -31,7 +34,7 @@ public sealed unsafe class CmpFile : MetaBaseFile
|
|||
}
|
||||
|
||||
public CmpFile()
|
||||
: base( CharacterUtility.HumanCmpIdx )
|
||||
: base( CharacterUtility.Index.HumanCmp )
|
||||
{
|
||||
AllocateData( DefaultData.Length );
|
||||
Reset();
|
||||
|
|
@ -39,7 +42,7 @@ public sealed unsafe class CmpFile : MetaBaseFile
|
|||
|
||||
public static float GetDefault( SubRace subRace, RspAttribute attribute )
|
||||
{
|
||||
var data = ( byte* )Penumbra.CharacterUtility.DefaultResource( CharacterUtility.HumanCmpIdx ).Address;
|
||||
var data = ( byte* )Penumbra.CharacterUtility.DefaultResource( InternalIndex ).Address;
|
||||
return *( float* )( data + RacialScalingStart + ToRspIndex( subRace ) * RspEntry.ByteSize + ( int )attribute * 4 );
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -114,8 +114,8 @@ public sealed unsafe class ExpandedEqdpFile : MetaBaseFile
|
|||
public EqdpEntry GetDefault( int setIdx )
|
||||
=> GetDefault( Index, setIdx );
|
||||
|
||||
public static EqdpEntry GetDefault( int fileIdx, int setIdx )
|
||||
=> GetDefault( ( byte* )Penumbra.CharacterUtility.DefaultResource( fileIdx ).Address, setIdx );
|
||||
public static EqdpEntry GetDefault( Interop.CharacterUtility.InternalIndex idx, int setIdx )
|
||||
=> GetDefault( ( byte* )Penumbra.CharacterUtility.DefaultResource( idx ).Address, setIdx );
|
||||
|
||||
public static EqdpEntry GetDefault( byte* data, int setIdx )
|
||||
{
|
||||
|
|
@ -139,5 +139,5 @@ public sealed unsafe class ExpandedEqdpFile : MetaBaseFile
|
|||
}
|
||||
|
||||
public static EqdpEntry GetDefault( GenderRace raceCode, bool accessory, int setIdx )
|
||||
=> GetDefault( CharacterUtility.EqdpIdx( raceCode, accessory ), setIdx );
|
||||
=> GetDefault( Interop.CharacterUtility.ReverseIndices[ ( int )CharacterUtility.EqdpIdx( raceCode, accessory ) ], setIdx );
|
||||
}
|
||||
|
|
@ -76,15 +76,15 @@ public unsafe class ExpandedEqpGmpBase : MetaBaseFile
|
|||
}
|
||||
|
||||
public ExpandedEqpGmpBase( bool gmp )
|
||||
: base( gmp ? CharacterUtility.GmpIdx : CharacterUtility.EqpIdx )
|
||||
: base( gmp ? CharacterUtility.Index.Gmp : CharacterUtility.Index.Eqp )
|
||||
{
|
||||
AllocateData( MaxSize );
|
||||
Reset();
|
||||
}
|
||||
|
||||
protected static ulong GetDefaultInternal( int fileIdx, int setIdx, ulong def )
|
||||
protected static ulong GetDefaultInternal( Interop.CharacterUtility.InternalIndex fileIndex, int setIdx, ulong def )
|
||||
{
|
||||
var data = ( byte* )Penumbra.CharacterUtility.DefaultResources[ fileIdx ].Address;
|
||||
var data = ( byte* )Penumbra.CharacterUtility.DefaultResource(fileIndex).Address;
|
||||
if( setIdx == 0 )
|
||||
{
|
||||
setIdx = 1;
|
||||
|
|
@ -112,6 +112,9 @@ public unsafe class ExpandedEqpGmpBase : MetaBaseFile
|
|||
|
||||
public sealed class ExpandedEqpFile : ExpandedEqpGmpBase, IEnumerable<EqpEntry>
|
||||
{
|
||||
public static readonly Interop.CharacterUtility.InternalIndex InternalIndex =
|
||||
Interop.CharacterUtility.ReverseIndices[ (int) CharacterUtility.Index.Eqp ];
|
||||
|
||||
public ExpandedEqpFile()
|
||||
: base( false )
|
||||
{ }
|
||||
|
|
@ -124,7 +127,7 @@ public sealed class ExpandedEqpFile : ExpandedEqpGmpBase, IEnumerable<EqpEntry>
|
|||
|
||||
|
||||
public static EqpEntry GetDefault( int setIdx )
|
||||
=> ( EqpEntry )GetDefaultInternal( CharacterUtility.EqpIdx, setIdx, ( ulong )Eqp.DefaultEntry );
|
||||
=> ( EqpEntry )GetDefaultInternal( InternalIndex, setIdx, ( ulong )Eqp.DefaultEntry );
|
||||
|
||||
protected override unsafe void SetEmptyBlock( int idx )
|
||||
{
|
||||
|
|
@ -156,6 +159,9 @@ public sealed class ExpandedEqpFile : ExpandedEqpGmpBase, IEnumerable<EqpEntry>
|
|||
|
||||
public sealed class ExpandedGmpFile : ExpandedEqpGmpBase, IEnumerable<GmpEntry>
|
||||
{
|
||||
public static readonly Interop.CharacterUtility.InternalIndex InternalIndex =
|
||||
Interop.CharacterUtility.ReverseIndices[( int )CharacterUtility.Index.Gmp];
|
||||
|
||||
public ExpandedGmpFile()
|
||||
: base( true )
|
||||
{ }
|
||||
|
|
@ -167,7 +173,7 @@ public sealed class ExpandedGmpFile : ExpandedEqpGmpBase, IEnumerable<GmpEntry>
|
|||
}
|
||||
|
||||
public static GmpEntry GetDefault( int setIdx )
|
||||
=> ( GmpEntry )GetDefaultInternal( CharacterUtility.GmpIdx, setIdx, ( ulong )GmpEntry.Default );
|
||||
=> ( GmpEntry )GetDefaultInternal( InternalIndex, setIdx, ( ulong )GmpEntry.Default );
|
||||
|
||||
public void Reset( IEnumerable< int > entries )
|
||||
{
|
||||
|
|
|
|||
|
|
@ -2,6 +2,7 @@ using System;
|
|||
using System.Runtime.InteropServices;
|
||||
using Penumbra.GameData.Enums;
|
||||
using Penumbra.GameData.Util;
|
||||
using Penumbra.Interop.Structs;
|
||||
using Penumbra.Meta.Manipulations;
|
||||
|
||||
namespace Penumbra.Meta.Files;
|
||||
|
|
@ -53,7 +54,7 @@ public sealed unsafe class EstFile : MetaBaseFile
|
|||
ResizeResources( Length + IncreaseSize );
|
||||
}
|
||||
|
||||
var control = ( Info* )( Data + 4 );
|
||||
var control = ( Info* )( Data + 4 );
|
||||
var entries = ( ushort* )( control + Count );
|
||||
|
||||
for( var i = Count - 1; i >= idx; --i )
|
||||
|
|
@ -95,7 +96,7 @@ public sealed unsafe class EstFile : MetaBaseFile
|
|||
|
||||
for( var i = idx; i < Count - 1; ++i )
|
||||
{
|
||||
entries[i - 2] = entries[i + 1];
|
||||
entries[ i - 2 ] = entries[ i + 1 ];
|
||||
}
|
||||
|
||||
entries[ Count - 3 ] = 0;
|
||||
|
|
@ -174,7 +175,7 @@ public sealed unsafe class EstFile : MetaBaseFile
|
|||
}
|
||||
|
||||
public EstFile( EstManipulation.EstType estType )
|
||||
: base( ( int )estType )
|
||||
: base( ( CharacterUtility.Index )estType )
|
||||
{
|
||||
var length = DefaultData.Length;
|
||||
AllocateData( length + IncreaseSize );
|
||||
|
|
@ -182,11 +183,11 @@ public sealed unsafe class EstFile : MetaBaseFile
|
|||
}
|
||||
|
||||
public ushort GetDefault( GenderRace genderRace, ushort setId )
|
||||
=> GetDefault( ( EstManipulation.EstType )Index, genderRace, setId );
|
||||
=> GetDefault( Index, genderRace, setId );
|
||||
|
||||
public static ushort GetDefault( EstManipulation.EstType estType, GenderRace genderRace, ushort setId )
|
||||
public static ushort GetDefault( Interop.CharacterUtility.InternalIndex index, GenderRace genderRace, ushort setId )
|
||||
{
|
||||
var data = ( byte* )Penumbra.CharacterUtility.DefaultResource( ( int )estType ).Address;
|
||||
var data = ( byte* )Penumbra.CharacterUtility.DefaultResource( index ).Address;
|
||||
var count = *( int* )data;
|
||||
var span = new ReadOnlySpan< Info >( data + 4, count );
|
||||
var (idx, found) = FindEntry( span, genderRace, setId );
|
||||
|
|
@ -197,4 +198,10 @@ public sealed unsafe class EstFile : MetaBaseFile
|
|||
|
||||
return *( ushort* )( data + 4 + count * EntryDescSize + idx * EntrySize );
|
||||
}
|
||||
|
||||
public static ushort GetDefault( CharacterUtility.Index index, GenderRace genderRace, ushort setId )
|
||||
=> GetDefault( Interop.CharacterUtility.ReverseIndices[ ( int )index ], genderRace, setId );
|
||||
|
||||
public static ushort GetDefault( EstManipulation.EstType estType, GenderRace genderRace, ushort setId )
|
||||
=> GetDefault( ( CharacterUtility.Index )estType, genderRace, setId );
|
||||
}
|
||||
|
|
@ -1,6 +1,7 @@
|
|||
using System;
|
||||
using Dalamud.Memory;
|
||||
using Penumbra.GameData.Util;
|
||||
using CharacterUtility = Penumbra.Interop.CharacterUtility;
|
||||
|
||||
namespace Penumbra.Meta.Files;
|
||||
|
||||
|
|
@ -8,10 +9,10 @@ public unsafe class MetaBaseFile : IDisposable
|
|||
{
|
||||
public byte* Data { get; private set; }
|
||||
public int Length { get; private set; }
|
||||
public int Index { get; }
|
||||
public CharacterUtility.InternalIndex Index { get; }
|
||||
|
||||
public MetaBaseFile( int idx )
|
||||
=> Index = idx;
|
||||
public MetaBaseFile( Interop.Structs.CharacterUtility.Index idx )
|
||||
=> Index = CharacterUtility.ReverseIndices[(int) idx];
|
||||
|
||||
protected (IntPtr Data, int Length) DefaultData
|
||||
=> Penumbra.CharacterUtility.DefaultResource( Index );
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue