@@ -996,6 +996,7 @@ private async Task<List<TexTypePath>> GetTexNames(IEnumerable<string> texPathLis
996
996
private static readonly Regex _weaponMatch = new Regex ( "(w[0-9]{4})" ) ;
997
997
private static readonly Regex _tailMatch = new Regex ( "(t[0-9]{4})" ) ;
998
998
private static readonly Regex _raceMatch = new Regex ( "(c[0-9]{4})" ) ;
999
+ private static readonly Regex _bodyRegex = new Regex ( "(b[0-9]{4})" ) ;
999
1000
private static readonly Regex _skinRegex = new Regex ( "^/mt_c([0-9]{4})b([0-9]{4})_.+\\ .mtrl$" ) ;
1000
1001
/// <summary>
1001
1002
/// Resolves the MTRL path for a given MDL path.
@@ -1020,11 +1021,27 @@ public string GetMtrlPath(string mdlPath, string mtrlName, int mtrlVariant = 1)
1020
1021
var mdlMatch = _raceMatch . Match ( mdlPath ) ;
1021
1022
var mtrlMatch = _raceMatch . Match ( mtrlName ) ;
1022
1023
1024
+
1023
1025
// Both Items have racial model information in their path, and the races DON'T match.
1024
1026
if ( mdlMatch . Success && mtrlMatch . Success && mdlMatch . Groups [ 1 ] . Value != mtrlMatch . Groups [ 1 ] . Value )
1025
1027
{
1026
- // In this case, we actually replace the race in the Material the race from the MODEL, which has priority.
1027
- mtrlName = mtrlName . Replace ( mtrlMatch . Groups [ 1 ] . Value , mdlMatch . Groups [ 1 ] . Value ) ;
1028
+
1029
+ // Need to find the racial skin for this race.
1030
+ var baseRace = XivRaces . GetXivRace ( mdlMatch . Groups [ 1 ] . Value . Substring ( 1 ) ) ;
1031
+ var skinRace = XivRaceTree . GetSkinRace ( baseRace ) ;
1032
+ var skinRaceString = "c" + XivRaces . GetRaceCode ( skinRace ) ;
1033
+
1034
+ // In this case, we actually replace both with the racial skin material based on the Model, which has priority.
1035
+ mtrlName = mtrlName . Replace ( mtrlMatch . Groups [ 1 ] . Value , skinRaceString ) ;
1036
+ mdlPath = mdlPath . Replace ( mdlMatch . Groups [ 1 ] . Value , skinRaceString ) ;
1037
+
1038
+ // If we actually shifted races, reset the body identifier.
1039
+ // This shouldn't really ever happen, but safety check.
1040
+ if ( baseRace != skinRace )
1041
+ {
1042
+ mtrlName = _bodyRegex . Replace ( mtrlName , "b0001" ) ;
1043
+ mdlPath = _bodyRegex . Replace ( mdlPath , "b0001" ) ;
1044
+ }
1028
1045
}
1029
1046
1030
1047
0 commit comments