From fcaf432d1eff563b47a082b8c63e42d2d83eba4a Mon Sep 17 00:00:00 2001 From: Matthew Musgrove Date: Wed, 23 Mar 2011 23:07:44 -0500 Subject: [PATCH] Fixing recall_all(). --- lib/Lacuna/RPC/Building/SpacePort.pm | 6 +++--- t/SpacePort.t | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/Lacuna/RPC/Building/SpacePort.pm b/lib/Lacuna/RPC/Building/SpacePort.pm index 164a5694..641639c1 100644 --- a/lib/Lacuna/RPC/Building/SpacePort.pm +++ b/lib/Lacuna/RPC/Building/SpacePort.pm @@ -219,16 +219,16 @@ sub recall_all { my ($self, $session_id, $building_id) = @_; my $empire = $self->get_empire_by_session($session_id); my $building = $self->get_building($empire, $building_id); - my $ships = $body->ships_orbiting->search(undef)->all; + my $body = $building->body; + my @ships = $body->ships_orbiting->search(undef)->all; my @ret; - while(my $ship = $ships->next) { + for my $ship (@ships) { unless (defined $ship) { confess [1002, 'Could not locate that ship.']; } unless ($ship->body->empire_id == $empire->id) { confess [1010, 'You do not own that ship.']; } - my $body = $building->body; $body->empire($empire); $ship->can_recall(); diff --git a/t/SpacePort.t b/t/SpacePort.t index ddb2a23d..646cf5c0 100644 --- a/t/SpacePort.t +++ b/t/SpacePort.t @@ -72,7 +72,7 @@ $result = $tester->post('spaceport', 'view_ships_orbiting', [$session_id, $space is(ref $result->{result}{ships_orbiting}, 'ARRAY', "can see orbiting ships"); $result = $tester->post('spaceport', 'recall_all', [$session_id, $spaceport->id]); -is(ref $result->{result}{ships}, 'ARRAY', 'can call recall-all'); +is(ref $result->{result}{ships}, 'ARRAY', 'can call recall_all'); my $shipyard = Lacuna::db->resultset('Lacuna::DB::Result::Building')->new({ x => 0, -- 2.51.2