@@ -519,6 +519,25 @@ int unembed(CommandLine& cli) {
519
519
return 0 ;
520
520
}
521
521
522
+ int rename_texture (CommandLine& cli) {
523
+ Bsp* map = new Bsp (cli.bspfile );
524
+ if (!map->valid )
525
+ return 1 ;
526
+
527
+ string oldName = cli.getOption (" -old" );
528
+ string newName = cli.getOption (" -new" );
529
+
530
+ map->rename_texture (oldName.c_str (), newName.c_str ());
531
+
532
+ if (map->isValid ()) map->write (cli.hasOption (" -o" ) ? cli.getOption (" -o" ) : map->path );
533
+ logf (" \n " );
534
+
535
+ delete map;
536
+
537
+ return 0 ;
538
+ }
539
+
540
+
522
541
void print_help (string command) {
523
542
if (command == " merge" ) {
524
543
logf (
@@ -631,6 +650,14 @@ void print_help(string command) {
631
650
" Example: bspguy unembed c1a0.bsp\n "
632
651
);
633
652
}
653
+ else if (command == " renametex" ) {
654
+ logf (
655
+ " renametex - Renames a texture. This changes the texture if it's loaded from a WAD.\n\n "
656
+
657
+ " Usage: bspguy renametex <mapname> -old <oldname> -new <newname>\n "
658
+ " Example: bspguy rename c1a0.bsp -old aaatrigger -new aaadigger\n "
659
+ );
660
+ }
634
661
else {
635
662
logf (" %s\n\n " , g_version_string);
636
663
logf (
@@ -645,6 +672,7 @@ void print_help(string command) {
645
672
" simplify : Simplify BSP models\n "
646
673
" transform : Apply 3D transformations to the BSP\n "
647
674
" unembed : Deletes embedded texture data\n "
675
+ " renametex : Renames/replaces a texture in the BSP\n "
648
676
649
677
" \n Run 'bspguy <command> help' to read about a specific command.\n "
650
678
" \n To launch the 3D editor. Drag and drop a .bsp file onto the executable,\n "
@@ -756,6 +784,9 @@ int main(int argc, char* argv[])
756
784
else if (cli.command == " unembed" ) {
757
785
return unembed (cli);
758
786
}
787
+ else if (cli.command == " renametex" ) {
788
+ return rename_texture (cli);
789
+ }
759
790
else {
760
791
logf (" unrecognized command: %d\n " , cli.command .c_str ());
761
792
}
0 commit comments