From 29d01e698b1b42ae2231bc0a31239f601418c1e0 Mon Sep 17 00:00:00 2001 From: Ottermandias Date: Sun, 1 Jan 2023 13:55:23 +0100 Subject: [PATCH] Fix swapping universal hairstyles for midlanders breaking them for others. --- Penumbra.GameData/Data/MaterialHandling.cs | 5 +++-- Penumbra/Mods/ItemSwap/CustomizationSwap.cs | 6 +++--- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/Penumbra.GameData/Data/MaterialHandling.cs b/Penumbra.GameData/Data/MaterialHandling.cs index 09bbab51..ef336a9d 100644 --- a/Penumbra.GameData/Data/MaterialHandling.cs +++ b/Penumbra.GameData/Data/MaterialHandling.cs @@ -22,10 +22,11 @@ public static class MaterialHandling // All hairstyles above 116 are shared except for Hrothgar if (hairId.Value is >= 116 and <= 200) - { return actualGr.Split().Item1 == Gender.Female ? GenderRace.MidlanderFemale : GenderRace.MidlanderMale; - } return actualGr; } + + public static bool IsSpecialCase(GenderRace gr, SetId hairId) + => gr is GenderRace.MidlanderMale or GenderRace.MidlanderFemale && hairId.Value is >= 101 and <= 200; } diff --git a/Penumbra/Mods/ItemSwap/CustomizationSwap.cs b/Penumbra/Mods/ItemSwap/CustomizationSwap.cs index b9e9a94f..f650818a 100644 --- a/Penumbra/Mods/ItemSwap/CustomizationSwap.cs +++ b/Penumbra/Mods/ItemSwap/CustomizationSwap.cs @@ -60,9 +60,9 @@ public static class CustomizationSwap var mtrlToPath = GamePaths.Character.Mtrl.Path( race, slot, idTo, fileName, out var gameRaceTo, out var gameSetIdTo, variant ); var newFileName = fileName; - newFileName = ItemSwap.ReplaceRace( newFileName, gameRaceTo, race, gameRaceTo != race ); - newFileName = ItemSwap.ReplaceBody( newFileName, slot, idTo, idFrom, idFrom.Value != idTo.Value ); - newFileName = ItemSwap.AddSuffix( newFileName, ".mtrl", $"_c{race.ToRaceCode()}", gameRaceFrom != race ); + newFileName = ItemSwap.ReplaceRace( newFileName, gameRaceTo, race, gameRaceTo != race ); + newFileName = ItemSwap.ReplaceBody( newFileName, slot, idTo, idFrom, idFrom.Value != idTo.Value ); + newFileName = ItemSwap.AddSuffix( newFileName, ".mtrl", $"_c{race.ToRaceCode()}", gameRaceFrom != race || MaterialHandling.IsSpecialCase( race, idFrom ) ); newFileName = ItemSwap.AddSuffix( newFileName, ".mtrl", $"_{slot.ToAbbreviation()}{idFrom.Value:D4}", gameSetIdFrom.Value != idFrom.Value ); var actualMtrlFromPath = mtrlFromPath;