Index: tools/entity/Entity.pm =================================================================== --- tools/entity/Entity.pm +++ tools/entity/Entity.pm @@ -129,17 +129,18 @@ sub find_entities { + my ($modName) = @_; my @files; my $find_process = sub { return $File::Find::prune = 1 if $_ eq '.svn'; my $n = $File::Find::name; return if /~$/; return unless -f $_; - $n =~ s~\Q$vfsroot\E/public/simulation/templates/~~; + $n =~ s~\Q$vfsroot\E/$modName/simulation/templates/~~; $n =~ s/\.xml$//; push @files, $n; }; - find({ wanted => $find_process }, "$vfsroot/public/simulation/templates"); + find({ wanted => $find_process }, "$vfsroot/$modName/simulation/templates"); return @files; } Index: tools/entity/checkrefs.pl =================================================================== --- tools/entity/checkrefs.pl +++ tools/entity/checkrefs.pl @@ -7,7 +7,9 @@ use Entity; -use constant CHECK_MAPS_XML => 0; +use constant CHECK_MAPS_XML => 1; +use constant CHECK_UNUSED => 1; +use constant VALIDATE_TEMPLATES => 1; use constant ROOT_ACTORS => 1; my @files; @@ -29,9 +31,8 @@ sub vfs_to_relative_to_mods { - my ($vfspath) = @_; - my $fn = "public/$vfspath"; - return $fn; + my ($vfsPath) = @_; + return "public/$vfsPath"; } sub find_files @@ -47,7 +48,16 @@ $n =~ s~\Q$vfsroot\E/(public|mod)/~~; push @files, $n; }; - find({ wanted => $find_process }, "$vfsroot/public/$vfspath"); + + if("../../../binaries/data/mods/public/gui/modmod/" eq "$vfsroot/public/$vfspath") + { + find({ wanted => $find_process }, "$vfsroot/mod/$vfspath"); + } + else + { + find({ wanted => $find_process }, "$vfsroot/public/$vfspath"); + } + find({ wanted => $find_process }, "$vfsroot/mod/$vfspath") if -d "$vfsroot/mod/$vfspath"; return @files; @@ -147,6 +157,33 @@ } } + +sub add_variants +{ + print "Loading variants...\n"; + my @variantfiles = find_files('art/variants', 'xml'); + + for my $f (sort @variantfiles) + { + push @files, $f; + push @roots, $f if ROOT_ACTORS; + my $variant = XMLin(vfs_to_physical($f), ForceArray => [qw(texture prop animation)], KeyAttr => []) or die "Failed to parse '$f': $!"; + push @deps, [ $f, "art/meshes/$variant->{mesh}" ] if $variant->{mesh}; + for my $tex (@{$variant->{textures}{texture}}) + { + push @deps, [ $f, "art/textures/skins/$tex->{file}" ] if $tex->{file}; + } + for my $prop (@{$variant->{props}{prop}}) + { + push @deps, [ $f, "art/actors/$prop->{actor}" ] if $prop->{actor}; + } + for my $anim (@{$variant->{animations}{animation}}) + { + push @deps, [ $f, "art/animation/$anim->{file}" ] if $anim->{file}; + } + } +} + sub add_art { print "Loading art files...\n"; @@ -440,9 +477,11 @@ push @roots, $f; my $rms = parse_json_file($f); + if($rms->{settings}{Script}) + { + push @deps, [ $f, "maps/random/" . $rms->{settings}{Script} ]; + } - push @deps, [ $f, "maps/random/" . $rms->{settings}{Script} ]; - # Map previews push @deps, [ $f, "art/textures/ui/session/icons/mappreview/" . $rms->{settings}{Preview} ] if $rms->{settings}{Preview}; } @@ -536,46 +575,38 @@ last if @newreachable == 0; @reachable{@newreachable} = (); } + my $terrains = "public/art/terrains/"; + my $random = "public/maps/random/"; + my $materials = "public/art/materials/"; for my $f (sort @files) { - next if exists $reachable{$f}; - warn "Unused file '" . vfs_to_relative_to_mods($f) . "'\n"; + my $fullPath = vfs_to_relative_to_mods($f); + next if exists $reachable{$f} || !(index($fullPath, $terrains) == -1 && index($fullPath, $random) == -1 && index($fullPath, $materials) == -1); + warn "Unused file '" . $fullPath . "'\n"; } } add_maps_xml() if CHECK_MAPS_XML; - add_maps_pmp(); - add_entities(); - add_actors(); - +add_variants(); add_art(); - add_materials(); - add_particles(); - add_soundgroups(); add_audio(); - add_gui_xml(); add_gui_data(); - add_civs(); - add_rms(); - add_techs(); - add_terrains(); -# TODO: add non-skin textures, and all the references to them - print "\n"; check_deps(); print "\n"; -check_unused(); +check_unused() if CHECK_UNUSED; +system("perl ../xmlvalidator/validate.pl") if VALIDATE_TEMPLATES; Index: tools/entity/entvalidate.pl =================================================================== --- tools/entity/entvalidate.pl +++ tools/entity/entvalidate.pl @@ -49,7 +49,7 @@ sub check_all { - my @files = Entity::find_entities(); + my @files = Entity::find_entities("public"); my $count = 0; my $failed = 0;