From 0277fcc750269c1507ed4728cc6207f94ec4df7c Mon Sep 17 00:00:00 2001 From: Allanis <allanis@saracraft.net> Date: Mon, 12 Aug 2013 09:39:10 +0100 Subject: [PATCH] [Fix] Turrets causing seg fault when there is no target. --- src/weapon.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/weapon.c b/src/weapon.c index 19c5c8a..384272d 100644 --- a/src/weapon.c +++ b/src/weapon.c @@ -406,7 +406,8 @@ static Weapon* weapon_create(const Outfit* outfit, const double dir, const Vec2* case OUTFIT_TYPE_BOLT: case OUTFIT_TYPE_TURRET_BOLT: /* Only difference is the direction of fire. */ - if((outfit->type == OUTFIT_TYPE_TURRET_BOLT) && (w->parent != w->target)) { + if((outfit->type == OUTFIT_TYPE_TURRET_BOLT) && (w->parent != w->target) && + (w->target != 0)) { /* Must have a valid target. */ rdir = vect_angle(pos, &pilot_get(w->target)->solid->pos); rdir += RNG(-outfit->u.blt.accuracy/2., outfit->u.blt.accuracy/2.)/180.*M_PI;