[Fix] Turrets causing seg fault when there is no target.

This commit is contained in:
Allanis 2013-08-12 09:39:10 +01:00
parent 284823ce25
commit 0277fcc750

View File

@ -406,7 +406,8 @@ static Weapon* weapon_create(const Outfit* outfit, const double dir, const Vec2*
case OUTFIT_TYPE_BOLT: case OUTFIT_TYPE_BOLT:
case OUTFIT_TYPE_TURRET_BOLT: case OUTFIT_TYPE_TURRET_BOLT:
/* Only difference is the direction of fire. */ /* 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 = vect_angle(pos, &pilot_get(w->target)->solid->pos);
rdir += RNG(-outfit->u.blt.accuracy/2., rdir += RNG(-outfit->u.blt.accuracy/2.,
outfit->u.blt.accuracy/2.)/180.*M_PI; outfit->u.blt.accuracy/2.)/180.*M_PI;