# HG changeset patch # User "Rex Tsai " # Date 1234360791 -28800 # Node ID 58b36b18809f23431d1d96c875235c8ab53be73c # Parent 1f5cd5c4f6b6a3ff86338a5ed160ea9723b89d4c new scanning tool diff -r 1f5cd5c4f6b6 -r 58b36b18809f Ikariam.pm --- a/Ikariam.pm Wed Feb 11 21:59:08 2009 +0800 +++ b/Ikariam.pm Wed Feb 11 21:59:51 2009 +0800 @@ -116,6 +116,7 @@ use YAML qw/LoadFile Dump DumpFile/; use IO::Uncompress::Gunzip qw(gunzip $GunzipError) ; use POSIX; +use JSON;; use utf8; sub new @@ -231,67 +232,30 @@ die('location required'); } - my $res = $self->{mech}->post(sprintf("http://%s/index.php?view=worldmap_iso", $self->{server}), [ - xajax => 'getMapData', - 'xajaxargs[]' => $x, - 'xajaxargs[]' => $y, - xajaxr => time, - ]); + my $res = $self->{mech}->post(sprintf("http://%s/index.php?action=WorldMap&function=getJSONArea&x_min=%d&x_max=%d&y_min=%d&y_max=%d", + $self->{server}, $x - 14, $x + 12, $y - 17, $y + 9), []); my $c; my $status = gunzip \$res->content => \$c or die "gunzip failed: $GunzipError\n"; + my $nodes = jsonToObj($c); my @islands; - # parsing xjxobj - while($c =~ /0<\/k><\/v><\/e>1<\/k><\/v><\/e>2<\/k><\/v><\/e>3<\/k><\/v><\/e>4<\/k><\/v><\/e>5<\/k><\/v><\/e>6<\/k><\/v><\/e>7<\/k><\/v><\/e><\/xjxobj><\/cmd>/g) - { - my %island; - $island{id} = $3; - $island{x} = $1; - $island{y} = $2; - $island{name} = $6; - $island{tradegood} = $4; - $island{wonder} = $5; - # $7 ? - $island{people} = $8; - push @islands, \%island; - } - return @islands; -} - -sub viewHomeMap -{ - my $self = shift; - - my $res = $self->{mech}->get(sprintf("http://%s/index.php?view=worldmap_iso", $self->{server})); - my $c; - my $status = gunzip \$res->content => \$c - or die "gunzip failed: $GunzipError\n"; - - # m[50][36]=new Array(564,1,5,'Risietia', '5', 13); - # x = 43-57 = 6 - # y = 27-41 = 6 - my @islands; - while($c =~ /m\[(\d+)\]\[(\d+)\]=new Array\((\d+),(\d+),(\d+),'(\w+)', '(\d+)', (\d+)\);/g) - { - my %island; - $island{id} = $3; - $island{x} = $1; - $island{y} = $2; - $island{name} = $6; - $island{tradegood} = $4; - $island{wonder} = $5; - # $7 ? - $island{people} = $8; - - #foreach my $i (sort(keys(%island))) - #{ - # printf ("%s %s\n", $i, $island{$i}); - #} - #print("\n"); - push @islands, \%island; + print $nodes->{'data'}; + foreach my $x (keys %{$nodes->{'data'}}) { + foreach my $y (keys(%{$nodes->{data}->{$x}})) { + my %island; + $island{id} = $nodes->{data}->{$x}->{$y}[0]; + $island{x} = $x; + $island{y} = $y; + $island{name} = $nodes->{data}->{$x}->{$y}[1]; + +# $island{tradegood} = $4; +# $island{wonder} = $5; +# $island{people} = $8; + push @islands, \%island; + } } return @islands; }