Share Pastebin
Guest
Public paste!

tanoh

By: a guest | May 7th, 2008 | Syntax: Perl | Size: 1.27 KB | Hits: 60 | Expires: Never
Copy text to clipboard
  1. #!/usr/bin/perl
  2. use strict;
  3. use vars qw ( %unit @temp );
  4. #
  5. # Lists guids from WoWCombatLog.txt and tries to find collisions in the spawncounter section
  6. #
  7. # Written by Tanoh for EJ discussion, use freely :>
  8. #
  9. open(FIL,"WoWCombatLog.txt") or die "d, aoh!";
  10. while( defined($_ = <FIL>) ) {
  11.         s/^(.+?)  //;
  12.         @temp = split(/,/);
  13.  
  14.         foreach my $i ( 1, 4 ) {
  15.                 if( (hex(substr($temp[$i],2,3)) & 0x00f) == 0x003 ) {
  16.                         $unit{$temp[$i]} = {
  17.                                 'name' => substr($temp[$i+1],1,-1),
  18.                                 'counter' => substr($temp[$i],13,6),
  19.                         };
  20.                 };
  21.         };
  22. };
  23. close(FIL);
  24.  
  25.  
  26. # check for counter collisions.
  27. foreach my $key ( keys %unit ) {
  28.         foreach my $otherkey ( keys %unit ) {
  29.                 next if( $otherkey eq $key );
  30.  
  31.                 if( hex($unit{$key}->{'counter'}) == hex($unit{$otherkey}->{'counter'}) ) {
  32.                         print "Collision! $key and $otherkey!\n";
  33.                 };
  34.         };
  35. };
  36.  
  37. # list counters and keys.
  38. foreach my $key ( sort {hex($unit{$a}->{'counter'}) <=> hex($unit{$b}->{'counter'})} keys %unit ) {
  39.         printf("%-25s: %s (%s)\n",$unit{$key}->{'name'},$unit{$key}->{'counter'},$key);
  40. };