From 1177685e62ae166ffec09d77c7dd3aa657cdea3d Mon Sep 17 00:00:00 2001 From: Allanis Date: Fri, 4 Oct 2013 00:02:33 +0100 Subject: [PATCH] [Fix] Beam stops moving if enemy got destroyed. --- src/weapon.c | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/src/weapon.c b/src/weapon.c index 0581d48..856432b 100644 --- a/src/weapon.c +++ b/src/weapon.c @@ -233,18 +233,19 @@ static void think_beam(Weapon* w, const double dt) { w->solid->pos.x = p->solid->pos.x; w->solid->pos.y = p->solid->pos.y; - t = pilot_get(w->target); - if(t == NULL) { - w->solid->dir_vel = 0.; - return; - } - /* Handle aiming. */ switch(w->outfit->type) { case OUTFIT_TYPE_BEAM: w->solid->dir = p->solid->dir; break; case OUTFIT_TYPE_TURRET_BEAM: + /* Get target, if target is dead beam stops moving. */ + t = pilot_get(w->target); + if(t == NULL) { + w->solid->dir_vel = 0.; + return; + } + if(w->target == w->parent) /* Invalid target, try to follow shooter. */ diff = angle_diff(w->solid->dir, p->solid->dir); else