@@ -463,25 +463,19 @@ private static string UpdateFolder(XivDependencyRoot Source, XivDependencyRoot D
463
463
{
464
464
if ( Destination . Info . PrimaryType == XivItemType . human && Destination . Info . SecondaryType == XivItemType . hair && Path . GetExtension ( path ) == ".mtrl" )
465
465
{
466
- // Hair material paths are actually hard-coded into the game, so there's some wild stuff that has to go on here.
467
- if ( Destination . Info . SecondaryId > 115 && Destination . Info . SecondaryId <= 200 )
468
- {
469
- // Hairs between 115 and 200 have forced material path sharing enabled.
470
- var digit3 = Destination . Info . SecondaryId / 100 ;
471
- var race = digit3 % 2 == 0 ? 101 : 201 ;
466
+ var hairRoot = Mtrl . GetHairMaterialRoot ( Destination . Info ) ;
472
467
473
- // Force the race code to the appropriate one.
474
- var raceReplace = new Regex ( "/c[0-9]{4}" ) ;
475
- path = raceReplace . Replace ( path , "/c" + race . ToString ( ) . PadLeft ( 4 , '0' ) ) ;
468
+ // Force the race code to the appropriate one.
469
+ var raceReplace = new Regex ( "/c[0-9]{4}" ) ;
470
+ path = raceReplace . Replace ( path , "/c" + hairRoot . PrimaryId . ToString ( ) . PadLeft ( 4 , '0' ) ) ;
476
471
477
- var hairReplace = new Regex ( "/h[0-9]{4}" ) ;
478
- path = hairReplace . Replace ( path , "/h" + Destination . Info . SecondaryId . ToString ( ) . PadLeft ( 4 , '0' ) ) ;
472
+ var hairReplace = new Regex ( "/h[0-9]{4}" ) ;
473
+ path = hairReplace . Replace ( path , "/h" + hairRoot . SecondaryId . ToString ( ) . PadLeft ( 4 , '0' ) ) ;
479
474
480
- // Hairs between 115 and 200 have forced material path sharing enabled.
481
- path = Path . GetDirectoryName ( path ) ;
482
- path = path . Replace ( '\\ ' , '/' ) ;
483
- return path ;
484
- }
475
+ // Hairs between 115 and 200 have forced material path sharing enabled.
476
+ path = Path . GetDirectoryName ( path ) ;
477
+ path = path . Replace ( '\\ ' , '/' ) ;
478
+ return path ;
485
479
}
486
480
487
481
// So first off, just copy anything from the old root folder to the new one.
@@ -511,28 +505,21 @@ private static string UpdateFileName(XivDependencyRoot Source, XivDependencyRoot
511
505
512
506
if ( Destination . Info . PrimaryType == XivItemType . human && Destination . Info . SecondaryType == XivItemType . hair && Path . GetExtension ( path ) == ".mtrl" )
513
507
{
514
- // Hair material paths are actually hard-coded into the game, so there's some wild stuff that has to go on here.
515
- if ( Destination . Info . SecondaryId > 115 && Destination . Info . SecondaryId <= 200 )
516
- {
517
- // Hairs between 115 and 200 have forced material path sharing enabled.
518
- var digit3 = Destination . Info . SecondaryId / 100 ;
519
- var race = digit3 % 2 == 0 ? 101 : 201 ;
508
+ var hairRoot = Mtrl . GetHairMaterialRoot ( Destination . Info ) ;
520
509
521
- // Force the race code to the appropriate one.
522
- var raceReplace = new Regex ( "^mt_c[0-9]{4}h[0-9]{4}" ) ;
523
- file = raceReplace . Replace ( file , "mt_c" + race . ToString ( ) . PadLeft ( 4 , '0' ) + "h" + Destination . Info . SecondaryId . ToString ( ) . PadLeft ( 4 , '0' ) ) ;
510
+ // Force replace the root information to the correct one for this target hair .
511
+ var raceReplace = new Regex ( "^mt_c[0-9]{4}h[0-9]{4}" ) ;
512
+ file = raceReplace . Replace ( file , "mt_c" + hairRoot . PrimaryId . ToString ( ) . PadLeft ( 4 , '0' ) + "h" + hairRoot . SecondaryId . ToString ( ) . PadLeft ( 4 , '0' ) ) ;
524
513
525
- // So for these, the first half of the filename is hard-coded locked (the c#### part)
526
- // We have to get gimmicky and play around with the suffixing.
527
- var initialPartRex = new Regex ( "^(mt_c[0-9]{4}h[0-9]{4})(?:_c[0-9]{4})?(.+)$" ) ;
528
- var m = initialPartRex . Match ( file ) ;
514
+ // Jam in a suffix into the MTRL to make it unique/non-colliding.
515
+ var initialPartRex = new Regex ( "^(mt_c[0-9]{4}h[0-9]{4})(?:_c[0-9]{4})?(.+)$" ) ;
516
+ var m = initialPartRex . Match ( file ) ;
529
517
530
- // ???
531
- if ( ! m . Success ) return file ;
518
+ // ???
519
+ if ( ! m . Success ) return file ;
532
520
533
- file = m . Groups [ 1 ] . Value + "_c" + Destination . Info . PrimaryId . ToString ( ) . PadLeft ( 4 , '0' ) + m . Groups [ 2 ] . Value ;
534
- return file ;
535
- }
521
+ file = m . Groups [ 1 ] . Value + "_c" + Destination . Info . PrimaryId . ToString ( ) . PadLeft ( 4 , '0' ) + m . Groups [ 2 ] . Value ;
522
+ return file ;
536
523
}
537
524
538
525
var rex = new Regex ( "[a-z][0-9]{4}([a-z][0-9]{4})" ) ;
0 commit comments