mirror of
https://github.com/xivdev/Penumbra.git
synced 2025-12-12 18:27:24 +01:00
Add a suffix of a stable hash of the original filename to texture paths.
This commit is contained in:
parent
5b3d5d1e67
commit
cc55ebb28f
2 changed files with 23 additions and 0 deletions
|
|
@ -144,6 +144,7 @@ public static class CustomizationSwap
|
||||||
|
|
||||||
var newPath = ReplaceAnyRace( path, race );
|
var newPath = ReplaceAnyRace( path, race );
|
||||||
newPath = ReplaceAnyBody( newPath, slot, idFrom );
|
newPath = ReplaceAnyBody( newPath, slot, idFrom );
|
||||||
|
newPath = AddSuffix( newPath, ".tex", $"_{Path.GetFileName(texture.Path).GetStableHashCode():x8}", true );
|
||||||
if( newPath != path )
|
if( newPath != path )
|
||||||
{
|
{
|
||||||
texture.Path = addedDashes ? newPath.Replace( "--", string.Empty ) : newPath;
|
texture.Path = addedDashes ? newPath.Replace( "--", string.Empty ) : newPath;
|
||||||
|
|
|
||||||
|
|
@ -109,4 +109,26 @@ public static class ItemSwap
|
||||||
file = null;
|
file = null;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static int GetStableHashCode( this string str )
|
||||||
|
{
|
||||||
|
unchecked
|
||||||
|
{
|
||||||
|
var hash1 = 5381;
|
||||||
|
var hash2 = hash1;
|
||||||
|
|
||||||
|
for( var i = 0; i < str.Length && str[ i ] != '\0'; i += 2 )
|
||||||
|
{
|
||||||
|
hash1 = ( ( hash1 << 5 ) + hash1 ) ^ str[ i ];
|
||||||
|
if( i == str.Length - 1 || str[ i + 1 ] == '\0' )
|
||||||
|
{
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
hash2 = ( ( hash2 << 5 ) + hash2 ) ^ str[ i + 1 ];
|
||||||
|
}
|
||||||
|
|
||||||
|
return hash1 + hash2 * 1566083941;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
Loading…
Add table
Add a link
Reference in a new issue