From 599e9e644116e2aa96ec87c528b3a0c73cfd2e54 Mon Sep 17 00:00:00 2001 From: JT Smith Date: Tue, 28 Dec 2010 10:34:16 -0600 Subject: [PATCH] - If you have ships heading to a body that becomes uninhabited while on route, the ships will now turn around and come home instead of falling dead. - If you have spies on a body that becomes uninhabited while they are on the planet, they will teleport home. --- lib/Lacuna/DB/Result/Map/Body/Planet.pm | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/lib/Lacuna/DB/Result/Map/Body/Planet.pm b/lib/Lacuna/DB/Result/Map/Body/Planet.pm index fba5ebbd..7351183e 100644 --- a/lib/Lacuna/DB/Result/Map/Body/Planet.pm +++ b/lib/Lacuna/DB/Result/Map/Body/Planet.pm @@ -115,9 +115,16 @@ sub sanitize { } $self->plans->delete; $self->glyphs->delete; - Lacuna->db->resultset('Lacuna::DB::Result::Ships')->search({foreign_body_id => $self->id})->delete_all; + my $incoming = Lacuna->db->resultset('Lacuna::DB::Result::Ships')->search({foreign_body_id => $self->id}); + while (my $ship = $incoming->next) { + $ship->turn_around->update; + } $self->ships->delete_all; - Lacuna->db->resultset('Lacuna::DB::Result::Spies')->search({on_body_id => $self->id})->delete_all; + my $enemy = Lacuna->db->resultset('Lacuna::DB::Result::Spies')->search({on_body_id => $self->id}); + while (my $spy = $enemy->next) { + $spy->on_body_id($spy->from_body_id); + $spy->update; + } Lacuna->db->resultset('Lacuna::DB::Result::Spies')->search({from_body_id => $self->id})->delete_all; Lacuna->db->resultset('Lacuna::DB::Result::Trades')->search({body_id => $self->id})->delete_all; Lacuna->db->resultset('Lacuna::DB::Result::Probes')->search({body_id => $self->id})->delete; -- 2.51.2