Extract Strings to separate submodule.

This commit is contained in:
Ottermandias 2022-10-29 15:53:45 +02:00
parent bc901f3ff6
commit 35baba18bf
75 changed files with 751 additions and 1657 deletions

View file

@ -4,6 +4,7 @@ using Penumbra.GameData.Structs;
using Penumbra.GameData.Util;
using Penumbra.Interop.Structs;
using System.Collections.Generic;
using Penumbra.String.Functions;
namespace Penumbra.Meta.Files;
@ -23,7 +24,7 @@ public sealed unsafe class CmpFile : MetaBaseFile
}
public override void Reset()
=> Functions.MemCpyUnchecked( Data, ( byte* )DefaultData.Data, DefaultData.Length );
=> MemoryUtility.MemCpyUnchecked( Data, ( byte* )DefaultData.Data, DefaultData.Length );
public void Reset( IEnumerable< (SubRace, RspAttribute) > entries )
{

View file

@ -4,6 +4,7 @@ using Penumbra.GameData.Enums;
using Penumbra.GameData.Structs;
using Penumbra.GameData.Util;
using Penumbra.Interop.Structs;
using Penumbra.String.Functions;
namespace Penumbra.Meta.Files;
@ -63,7 +64,7 @@ public sealed unsafe class ExpandedEqdpFile : MetaBaseFile
public override void Reset()
{
var def = ( byte* )DefaultData.Data;
Functions.MemCpyUnchecked( Data, def, IdentifierSize + PreambleSize );
MemoryUtility.MemCpyUnchecked( Data, def, IdentifierSize + PreambleSize );
var controlPtr = ( ushort* )( def + IdentifierSize + PreambleSize );
var dataBasePtr = controlPtr + BlockCount;
@ -73,18 +74,18 @@ public sealed unsafe class ExpandedEqdpFile : MetaBaseFile
{
if( controlPtr[ i ] == CollapsedBlock )
{
Functions.MemSet( myDataPtr, 0, BlockSize * EqdpEntrySize );
MemoryUtility.MemSet( myDataPtr, 0, BlockSize * EqdpEntrySize );
}
else
{
Functions.MemCpyUnchecked( myDataPtr, dataBasePtr + controlPtr[ i ], BlockSize * EqdpEntrySize );
MemoryUtility.MemCpyUnchecked( myDataPtr, dataBasePtr + controlPtr[ i ], BlockSize * EqdpEntrySize );
}
myControlPtr[ i ] = ( ushort )( i * BlockSize );
myDataPtr += BlockSize;
}
Functions.MemSet( myDataPtr, 0, Length - ( int )( ( byte* )myDataPtr - Data ) );
MemoryUtility.MemSet( myDataPtr, 0, Length - ( int )( ( byte* )myDataPtr - Data ) );
}
public void Reset( IEnumerable< int > entries )

View file

@ -5,6 +5,7 @@ using System.Numerics;
using Penumbra.GameData.Structs;
using Penumbra.GameData.Util;
using Penumbra.Interop.Structs;
using Penumbra.String.Functions;
namespace Penumbra.Meta.Files;
@ -49,7 +50,7 @@ public unsafe class ExpandedEqpGmpBase : MetaBaseFile
protected virtual void SetEmptyBlock( int idx )
{
Functions.MemSet( Data + idx * BlockSize * EntrySize, 0, BlockSize * EntrySize );
MemoryUtility.MemSet( Data + idx * BlockSize * EntrySize, 0, BlockSize * EntrySize );
}
public sealed override void Reset()
@ -62,7 +63,7 @@ public unsafe class ExpandedEqpGmpBase : MetaBaseFile
var collapsed = ( ( controlBlock >> i ) & 1 ) == 0;
if( !collapsed )
{
Functions.MemCpyUnchecked( Data + i * BlockSize * EntrySize, ptr + expandedBlocks * BlockSize * EntrySize, BlockSize * EntrySize );
MemoryUtility.MemCpyUnchecked( Data + i * BlockSize * EntrySize, ptr + expandedBlocks * BlockSize * EntrySize, BlockSize * EntrySize );
expandedBlocks++;
}
else

View file

@ -4,6 +4,7 @@ using Penumbra.GameData.Enums;
using Penumbra.GameData.Util;
using Penumbra.Interop.Structs;
using Penumbra.Meta.Manipulations;
using Penumbra.String.Functions;
namespace Penumbra.Meta.Files;
@ -170,8 +171,8 @@ public sealed unsafe class EstFile : MetaBaseFile
{
var (d, length) = DefaultData;
var data = ( byte* )d;
Functions.MemCpyUnchecked( Data, data, length );
Functions.MemSet( Data + length, 0, Length - length );
MemoryUtility.MemCpyUnchecked( Data, data, length );
MemoryUtility.MemSet( Data + length, 0, Length - length );
}
public EstFile( EstManipulation.EstType estType )

View file

@ -1,11 +1,12 @@
using System;
using System.Numerics;
using Newtonsoft.Json;
using Penumbra.GameData.ByteString;
using OtterGui;
using Penumbra.GameData.Enums;
using Penumbra.GameData.Util;
using Penumbra.Interop.Structs;
using Penumbra.Meta.Manipulations;
using Penumbra.String.Classes;
using Penumbra.String.Functions;
namespace Penumbra.Meta.Files;
@ -150,7 +151,7 @@ public unsafe class ImcFile : MetaBaseFile
var defaultPtr = ( ImcEntry* )( Data + PreambleSize );
for( var i = oldCount + 1; i < numVariants + 1; ++i )
{
Functions.MemCpyUnchecked( defaultPtr + i * NumParts, defaultPtr, NumParts * sizeof( ImcEntry ) );
MemoryUtility.MemCpyUnchecked( defaultPtr + i * NumParts, defaultPtr, NumParts * sizeof( ImcEntry ) );
}
Penumbra.Log.Verbose( $"Expanded IMC {Path} from {oldCount} to {numVariants} variants." );
@ -188,8 +189,8 @@ public unsafe class ImcFile : MetaBaseFile
var file = Dalamud.GameData.GetFile( Path.ToString() );
fixed( byte* ptr = file!.Data )
{
Functions.MemCpyUnchecked( Data, ptr, file.Data.Length );
Functions.MemSet( Data + file.Data.Length, 0, Length - file.Data.Length );
MemoryUtility.MemCpyUnchecked( Data, ptr, file.Data.Length );
MemoryUtility.MemSet( Data + file.Data.Length, 0, Length - file.Data.Length );
}
}
@ -207,7 +208,7 @@ public unsafe class ImcFile : MetaBaseFile
{
NumParts = BitOperations.PopCount( *( ushort* )( ptr + 2 ) );
AllocateData( file.Data.Length );
Functions.MemCpyUnchecked( Data, ptr, file.Data.Length );
MemoryUtility.MemCpyUnchecked( Data, ptr, file.Data.Length );
}
}
@ -243,7 +244,7 @@ public unsafe class ImcFile : MetaBaseFile
return;
}
Functions.MemCpyUnchecked( newData, Data, ActualLength );
MemoryUtility.MemCpyUnchecked( newData, Data, ActualLength );
Penumbra.MetaFileManager.Free( data, length );
resource->SetData( ( IntPtr )newData, ActualLength );

View file

@ -1,6 +1,7 @@
using System;
using Dalamud.Memory;
using Penumbra.GameData.Util;
using Penumbra.String.Functions;
using CharacterUtility = Penumbra.Interop.CharacterUtility;
namespace Penumbra.Meta.Files;
@ -57,12 +58,12 @@ public unsafe class MetaBaseFile : IDisposable
var data = ( byte* )Penumbra.MetaFileManager.AllocateFileMemory( ( ulong )newLength );
if( newLength > Length )
{
Functions.MemCpyUnchecked( data, Data, Length );
Functions.MemSet( data + Length, 0, newLength - Length );
MemoryUtility.MemCpyUnchecked( data, Data, Length );
MemoryUtility.MemSet( data + Length, 0, newLength - Length );
}
else
{
Functions.MemCpyUnchecked( data, Data, newLength );
MemoryUtility.MemCpyUnchecked( data, Data, newLength );
}
ReleaseUnmanagedResources();

View file

@ -2,11 +2,12 @@ using System;
using System.Collections.Generic;
using FFXIVClientStructs.FFXIV.Client.System.Resource;
using OtterGui.Filesystem;
using Penumbra.GameData.ByteString;
using Penumbra.GameData.Enums;
using Penumbra.Interop.Structs;
using Penumbra.Meta.Files;
using Penumbra.Meta.Manipulations;
using Penumbra.String;
using Penumbra.String.Classes;
namespace Penumbra.Meta.Manager;
@ -149,7 +150,7 @@ public partial class MetaManager
=> new($"|{_collection.Name}_{_collection.ChangeCounter}|{path}");
private static unsafe bool ImcLoadHandler( Utf8String split, Utf8String path, ResourceManager* resourceManager,
private static unsafe bool ImcLoadHandler( ByteString split, ByteString path, ResourceManager* resourceManager,
SeFileDescriptor* fileDescriptor, int priority, bool isSync, out byte ret )
{
ret = 0;

View file

@ -2,10 +2,10 @@ using System;
using System.Runtime.InteropServices;
using Newtonsoft.Json;
using Newtonsoft.Json.Converters;
using Penumbra.GameData.ByteString;
using Penumbra.GameData.Enums;
using Penumbra.Interop.Structs;
using Penumbra.Meta.Files;
using Penumbra.String.Classes;
namespace Penumbra.Meta.Manipulations;

View file

@ -4,6 +4,7 @@ using Newtonsoft.Json;
using Newtonsoft.Json.Converters;
using Penumbra.GameData.Util;
using Penumbra.Interop.Structs;
using Penumbra.String.Functions;
namespace Penumbra.Meta.Manipulations;
@ -217,7 +218,7 @@ public readonly struct MetaManipulation : IEquatable< MetaManipulation >, ICompa
{
fixed( MetaManipulation* lhs = &this )
{
return Functions.MemCmpUnchecked( lhs, &other, sizeof( MetaManipulation ) );
return MemoryUtility.MemCmpUnchecked( lhs, &other, sizeof( MetaManipulation ) );
}
}