3 # Quick & dirty script to find booboos in FlightGear animation files
4 # May 2004 Joshua Babcock jbabcock@atlantech.net
9 print "Usage: $0 <xml file> <ac3d file>\n";
21 # Put whatever you want in here to check for poorly formatted object names.
24 $_[0] !~ /^[A-Z].*/ && ($Bad=1);
25 $_[0] =~ /\W/ && ($Bad=1);
26 print "$_[0] poorly formatted\n" if $Bad;
29 # Make a hash of all the object names in the AC3D file.
30 open (AC3D, $ARGV[1]) or die "Could not open $ARGV[1]";
32 /^name \"(.*)\"/ && ($Objects{$1}+=1);
36 # Check for duplicates and proper format.
37 foreach $Key (keys %Objects) {
38 print "$Objects{$Key} instances of $1\n" if ($Objects{$Key}>1);
39 &CheckForm($Key) if $CheckForm;
42 print "$ObjCount objects found.\n\n";
44 # Make a hash of objects in the XML file that do not reference an object in the AC3D file.
45 open (XML, $ARGV[0]) or die "Could not open $ARGV[0]";
47 if (m|<object-name>(.*)</object-name>| && ! exists($Objects{$1})) {
48 # voodoo, "Perl Cookbook", p140
49 push( @{$References{$1}}, $.);
54 # List all the bad referencees.
55 foreach $Key (keys %References) {
57 print "Non-existant object $Key at line";
58 print "s" if (scalar( @{$References{$Key}}) > 1);
60 foreach $Num (@{$References{$Key}}) {
61 $First ? ($First=0) : (print ",");