Mercurial > eagle-eye
diff Ikariam.pm @ 326:58b36b18809f
new scanning tool
author | "Rex Tsai <chihchun@kalug.linux.org.tw>" |
---|---|
date | Wed, 11 Feb 2009 21:59:51 +0800 |
parents | b3b845d30d4b |
children | 484aaddeef66 |
line wrap: on
line diff
--- 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 =~ /<cmd n="jc" t="addToMap"><xjxobj><e><k>0<\/k><v><!\[CDATA\[(\d+)\]\]><\/v><\/e><e><k>1<\/k><v><!\[CDATA\[(\d+)\]\]><\/v><\/e><e><k>2<\/k><v><!\[CDATA\[(\d+)\]\]><\/v><\/e><e><k>3<\/k><v><!\[CDATA\[(\d+)\]\]><\/v><\/e><e><k>4<\/k><v><!\[CDATA\[(\d+)\]\]><\/v><\/e><e><k>5<\/k><v><!\[CDATA\[(\w+)\]\]><\/v><\/e><e><k>6<\/k><v><!\[CDATA\[(\d+)\]\]><\/v><\/e><e><k>7<\/k><v><!\[CDATA\[(\d+)\]\]><\/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; }