1 # Call with the following args:
2 # [-s <groupSize>] filename1 [filename 2 [...]]
4 # <groupSize> defines the size of the square within which nearby entries will be considered to be at the same location.
10 my %crashCountByLocation;
25 sub quantizeCoordinate
27 my $coordinate = shift;
28 return int(abs($coordinate)/$groupSize) * $groupSize * sign
($coordinate);
33 my $terrainName = shift;
34 my $x = quantizeCoordinate
(shift);
36 my $z = quantizeCoordinate
(shift);
38 my $key = $terrainName . ':' . $x . ':' . $z;
39 ++$crashCountByLocation{$key};
44 printf("count\t%25s: %6s %6s\n\n", 'terrain file', 'x', 'z');
46 # Sort entries by count, starting with highest.
47 foreach my $key (sort { $crashCountByLocation{$b} <=> $crashCountByLocation{$a} } keys %crashCountByLocation)
49 my $count = $crashCountByLocation{$key};
51 my @keyData = split(/:/, $key);
52 my $terrain = $keyData[0];
56 printf("%d\t%25s: %6d %6d\n", $count, $terrain, $x, $z);
61 if (defined($ARGV[0]) && ($ARGV[0] eq '-s'))
67 print "group size: $groupSize\n" if $debug;
84 elsif (m/^Player:\s*(\S+)\s+(\S+)\s+(\S+)/)
90 # This line depends on the Player entry coming after the Terrain entry in a .txt file.
91 addCrashLocation
($terrain, $x, $y, $z);