diff --git a/lib/Lacuna/RPC/Building/SpacePort.pm b/lib/Lacuna/RPC/Building/SpacePort.pm index 7967bd1e..4ca2ed69 100644 --- a/lib/Lacuna/RPC/Building/SpacePort.pm +++ b/lib/Lacuna/RPC/Building/SpacePort.pm @@ -650,6 +650,20 @@ sub fetch_spies { my $max_berth = $to_body->max_berth; + # get a spies + my @ids_fetched; + my @ids_not_fetched; + my $spies = Lacuna->db->resultset('Lacuna::DB::Result::Spies'); + foreach my $id (@{$spy_ids}) { + my $spy = $spies->find($id); + if ($spy->on_body_id == $on_body_id) { + push @ids_fetched, $id; + } + else { + push @ids_not_fetched, $id; + } + } + # get the ship my $ship = Lacuna->db->resultset('Lacuna::DB::Result::Ships')->find($ship_id); unless (defined $ship) { @@ -667,26 +681,28 @@ sub fetch_spies { confess [1013, "Cannot fetch spies from an uninhabited planet."]; } - unless (scalar(@{$spy_ids})) { - confess [1013, "You can't send a ship to collect no spies."]; + unless (scalar(@ids_fetched)) { + confess [1013, "You can't send a ship to collect no one."]; } # check size - if ($ship->type eq 'spy_shuttle' && scalar(@{$spy_ids}) <= 4) { + if ($ship->type eq 'spy_shuttle' && scalar(@ids_fetched) <= 4) { # we're ok } - elsif ($ship->hold_size <= (scalar(@{$spy_ids}) * 350)) { + elsif ($ship->hold_size <= (scalar(@ids_fetched) * 350)) { confess [1013, "The ship cannot hold the spies selected."]; } # send it $ship->send( target => $on_body, - payload => { fetch_spies => $spy_ids }, + payload => { fetch_spies => \@ids_fetched }, ); return { ship => $ship->get_status, + spies_fetched => \@ids_fetched, + spies_not_fetched => \@ids_not_fetched, status => $self->format_status($empire, $to_body), }; } diff --git a/lib/Lacuna/Role/Ship/Arrive/PickUpSpies.pm b/lib/Lacuna/Role/Ship/Arrive/PickUpSpies.pm index 9117abf9..cd010c09 100644 --- a/lib/Lacuna/Role/Ship/Arrive/PickUpSpies.pm +++ b/lib/Lacuna/Role/Ship/Arrive/PickUpSpies.pm @@ -46,6 +46,7 @@ after handle_arrival_procedures => sub { # object_type => ref($self), # object_id => $self->id, #})->insert; + next unless ($spy->on_body_id == $self->foreign_body_id); push @riding, $spy->id; my $duration = $self->date_available - $self->date_started; $spy->send($self->body_id, $self->date_available->clone->add_duration($duration))->update; diff --git a/var/www/public/changes.txt b/var/www/public/changes.txt index ffaa0638..6122113f 100644 --- a/var/www/public/changes.txt +++ b/var/www/public/changes.txt @@ -1,5 +1,6 @@ 3.0895: - Fix: Bad error message when not enough glyphs for a mission fixed. + - Fix: Fetch Spies exploit filled in. 3.0894: - API: repair_list checks number of fed building ids, rejection of call if over max building count.