Merge branch 'master' of https://Governor-Tarkin@bitbucket.org/Governor-Tarkin/swg...
[swg-src.git] / tools / buildQuestCrcStringTables.pl
blob59f48cc5b181068648389770ed2de1fe5937fb61
1 #!/usr/bin/perl
2 use strict;
3 use warnings;
5 my $branch;
6 my $all = "";
7 my $only = "";
10 # =====================================================================
12 sub perforceWhere
14 # find out where a perforce file resides on the local machine
15 my $result;
17 open(P4, "p4 where $_[0] |");
18 while ( <P4> )
20 next if ( /^-/ );
21 chomp;
22 my @where = split;
23 $result = $where[2];
25 close(P4);
28 return $result;
31 sub usage
33 die "usage: buildQuestCrcStringTables [--local|--all|--only <changelist#>] <current|stage|test|live|x1|x2|ep3|demo|s#>\n" .
34 "\t--local : include pending files only from the local client\n" .
35 "\t--all : include pending files from all clients\n" .
36 "\t--only <changelist#> : include pending files only from <changelist#>\n" .
37 "\tif no option is provided, --local is assumed.\n";
40 # =====================================================================
42 sub perforceGatherAndPrune
44 local $_;
45 my %files;
47 foreach my $spec (@_)
49 open(P4, "p4 files $spec/... |");
50 while (<P4>)
52 chomp;
53 next if (/ delete /)/
54 s%//depot/swg/$branch/data/sku\.0/sys\.(shared|server)/compiled/game/datatables/questlist/%%;
55 s/\.iff//;
56 s/#.*//;
57 $files{$_} = 1;
59 close(P4);
61 open(P4, "p4 opened " . $all . " " . $only . " $spec/... |");
62 while (<P4>)
64 chomp;
65 s%//depot/swg/$branch/data/sku\.0/sys\.(shared|server)/compiled/game/datatables/questlist/%%;
66 s/\.iff//;
67 s/#.*//;
68 $files{$_} = 1;
70 close(P4);
73 return sort keys %files;
76 # =====================================================================
78 if ($#ARGV == 1 || $#ARGV == 2)
80 if ($ARGV[0] eq "--local")
82 $all = "";
84 elsif ($ARGV[0] eq "--all")
86 $all = "-a";
88 elsif ($ARGV[0] eq "--only" && $#ARGV == 2)
90 $all = "";
91 $only = "-c " . $ARGV[1];
92 shift;
94 else
96 usage();
99 shift;
102 usage() unless (defined($ARGV[0]) && $ARGV[0] =~ m%^(current|stage|test|live|x1|x2|ep3|demo|s\d+)$%);
104 $branch = $ARGV[0];
107 my $tab = perforceWhere("//depot/swg/$branch/dsrc/sku.0/sys.shared/built/game/misc/quest_crc_string_table.tab");
108 my $output = perforceWhere("//depot/swg/$branch/data/sku.0/sys.shared/built/game/misc/quest_crc_string_table.iff");
109 print "building quest template strings:\n\t$tab\n\t$output\n";
110 system("p4 edit $tab $output");
112 my @files = perforceGatherAndPrune("//depot/swg/$branch/data/sku.0/sys.shared/compiled/game/datatables/questlist");
114 open(B, "| perl buildCrcStringTable.pl -t $tab $output");
115 foreach (@files)
117 print B $_, "\n";
119 close(B);