# HG changeset patch # User "Rex Tsai " # Date 1225688179 -28800 # Node ID e9f1110573929d5fd637f6d9bc8e330bcdea3ce5 # Parent b33c8dbe9b04394b9a8ed153adbb0c069c96e4e4 fixed the build new building function. diff -r b33c8dbe9b04 -r e9f111057392 Ikariam.pm --- a/Ikariam.pm Mon Nov 03 12:00:54 2008 +0800 +++ b/Ikariam.pm Mon Nov 03 12:56:19 2008 +0800 @@ -546,16 +546,27 @@ } if($position == -1) { - foreach (0..$#locations) { - # XXX - next if($_ <= 2 && ($self->{buildingIDs}->{$type} ne "workshop-fleet" && - $self->{buildingIDs}->{$type} ne "shipyard")); - if($locations[$_] eq undef) { - my $res = $self->{mech}->get(sprintf('http://%s/index.php?action=CityScreen&function=build&id=%s&position=%s&building=%d', - $self->{server}, $cityId, $_, $self->{buildingIDs}->{$type} )); - last; + my $targetPosition = undef; + if($type eq "wall") { + # 14 is wall. + $targetPosition = 14; + } else { + foreach (0..13) { + next if($_ <= 2 && ($type ne "workshop-fleet" && + $type ne "shipyard")); + + if($locations[$_] eq undef) { + $targetPosition = $_; + last; + } } } + + my $res = $self->{mech}->get(sprintf('http://%s/index.php?view=buildingGround&id=%s&position=%s', + $self->{server}, $cityId, $targetPosition)); + my $url = + Ikariam::Extractor->new(content => $res->content)->find(sprintf('//li[@class="building %s"]//a/@href', $type)); + $self->{mech}->get($url) if(defined($url)); } else { my $res = $self->{mech}->get (sprintf("http://%s/index.php?view=%s&id=%s&position=%d", $self->{server}, $type, $cityId, $position)); my $url = Ikariam::Extractor->new(content => $res->content)->find('//a[@title="升級建築物"]/@href');