From 9d7190f966c2be6f9eaecb5ad76b3dc45020f32b Mon Sep 17 00:00:00 2001 From: Eric Walch Date: Tue, 18 Oct 2011 19:58:37 +0000 Subject: [PATCH] Prevent a freeze when a ship script tries to resurrects a ship on dying because of an energy blast (Bug #18054). Ship now will just die. git-svn-id: http://svn.berlios.de/svnroot/repos/oolite-linux/trunk@4624 127b21dd-08f5-0310-b4b7-95ae10353056 --- src/Core/Entities/ShipEntity.h | 2 +- src/Core/Entities/ShipEntity.m | 10 +++++++--- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/src/Core/Entities/ShipEntity.h b/src/Core/Entities/ShipEntity.h index 12e2e402..9bb96d19 100644 --- a/src/Core/Entities/ShipEntity.h +++ b/src/Core/Entities/ShipEntity.h @@ -866,7 +866,7 @@ Vector positionOffsetForShipInRotationToAlignment(ShipEntity* ship, Quaternion q - (OOTimeDelta) missileLoadTime; - (void) setMissileLoadTime:(OOTimeDelta)newMissileLoadTime; - (BOOL) fireECM; -- (void) cascadeIfAppropriateWithDamageAmount:(double)amount cascadeOwner:(Entity *)owner; +- (BOOL) cascadeIfAppropriateWithDamageAmount:(double)amount cascadeOwner:(Entity *)owner; - (BOOL) activateCloakingDevice; - (void) deactivateCloakingDevice; - (BOOL) launchCascadeMine; diff --git a/src/Core/Entities/ShipEntity.m b/src/Core/Entities/ShipEntity.m index c694eb95..324829f3 100644 --- a/src/Core/Entities/ShipEntity.m +++ b/src/Core/Entities/ShipEntity.m @@ -8691,8 +8691,9 @@ Vector positionOffsetForShipInRotationToAlignment(ShipEntity* ship, Quaternion q } -- (void) cascadeIfAppropriateWithDamageAmount:(double)amount cascadeOwner:(Entity *)owner +- (BOOL) cascadeIfAppropriateWithDamageAmount:(double)amount cascadeOwner:(Entity *)owner { + BOOL cascade = NO; switch ([self scanClass]) { case CLASS_WORMHOLE: @@ -8720,11 +8721,12 @@ Vector positionOffsetForShipInRotationToAlignment(ShipEntity* ship, Quaternion q // ...start a chain reaction, if we're dying and have a non-trivial amount of energy. if (energy < amount && energy > 10 && [self countsAsKill]) { - [UNIVERSE addEntity:[OOQuiriumCascadeEntity quiriumCascadeFromShip:self]]; + cascade = [UNIVERSE addEntity:[OOQuiriumCascadeEntity quiriumCascadeFromShip:self]]; } break; //no default thanks, we want the compiler to tell us if we missed a case. } + return cascade; } @@ -8734,9 +8736,10 @@ Vector positionOffsetForShipInRotationToAlignment(ShipEntity* ship, Quaternion q if (amount <= 0.0) return; BOOL energyMine = [ent isCascadeWeapon]; + BOOL cascade = NO; if (energyMine) { - [self cascadeIfAppropriateWithDamageAmount:amount cascadeOwner:[ent owner]]; + cascade = [self cascadeIfAppropriateWithDamageAmount:amount cascadeOwner:[ent owner]]; } energy -= amount; @@ -8856,6 +8859,7 @@ Vector positionOffsetForShipInRotationToAlignment(ShipEntity* ship, Quaternion q if (!suppressExplosion) { [self noteTakingDamage:amount from:other type:damageType]; + if (cascade) energy = 0.0; // explicit set energy to zero in case an oxp raised the energy in previous line. } // die if I'm out of energy