From eaa453335563d670d856da44bf4ea1f332c618a7 Mon Sep 17 00:00:00 2001 From: rhyskidd Date: Wed, 30 May 2012 13:26:32 +0000 Subject: Ensure check for NULL pointer occurs prior to use, not after --- Stars45/Sim.cpp | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) (limited to 'Stars45/Sim.cpp') diff --git a/Stars45/Sim.cpp b/Stars45/Sim.cpp index e5482da..6d1f0fc 100644 --- a/Stars45/Sim.cpp +++ b/Stars45/Sim.cpp @@ -1,6 +1,6 @@ /* Project Starshatter 5.0 Destroyer Studios LLC - Copyright © 1997-2007. All Rights Reserved. + Copyright (C) 1997-2007. All Rights Reserved. SUBSYSTEM: Stars.exe FILE: Sim.cpp @@ -2733,11 +2733,14 @@ SimRegion::DamageShips() // then delete the ship: if (ship_destroyed) { NetUtil::SendObjKill(ship, owner, shot->IsMissile() ? NetObjKill::KILL_SECONDARY : NetObjKill::KILL_PRIMARY); - + Director* director; + Print(" %s Killed %s (%s)\n", owner_name, ship->Name(), FormatGameTime()); - // alert the killer - Director* director = owner->GetDirector(); + if (owner) + director = owner->GetDirector(); + + // alert the killer if (director && director->Type() > SteerAI::SEEKER && director->Type() < SteerAI::GROUND) { ShipAI* shipAI = (ShipAI*) director; shipAI->Splash(ship); -- cgit v1.1