Fix ghost ship bug with defense targets
Fix non-frangible subentities taking heat damage git-svn-id: http://svn.berlios.de/svnroot/repos/oolite-linux/trunk@5652 127b21dd-08f5-0310-b4b7-95ae10353056
This commit is contained in:
parent
20dd11afd6
commit
2c45d6ecde
@ -25,6 +25,8 @@ Changes between Oolite 1.77 and Oolite 1.77.1:
|
||||
* Use correct types in JS Station.market object
|
||||
* Fix bug with docking with stations where dock is very slightly off-axis
|
||||
* Fix contract reputation calculations so that negative rep works properly
|
||||
* Fix inconsistency with cloaking device behaviour
|
||||
* Fix calculation of heat damage to subentities
|
||||
|
||||
-------------------------------------------------------------------------------
|
||||
|
||||
|
@ -5278,7 +5278,7 @@ ShipEntity* doOctreesCollide(ShipEntity* prime, ShipEntity* other)
|
||||
// can't fire on primary target; track secondary targets instead
|
||||
NSEnumerator *targetEnum = [turret_owner defenseTargetEnumerator];
|
||||
Entity *target = nil;
|
||||
while ((target = [targetEnum nextObject]))
|
||||
while ((target = [[targetEnum nextObject] weakRefUnderlyingObject]))
|
||||
{
|
||||
if ([target scanClass] == CLASS_NO_DRAW || [(ShipEntity *)target isCloaked] || [target energy] <= 0.0)
|
||||
{
|
||||
@ -9658,14 +9658,14 @@ Vector positionOffsetForShipInRotationToAlignment(ShipEntity* ship, Quaternion q
|
||||
_defenseTargets = [[OOWeakSet alloc] init];
|
||||
}
|
||||
|
||||
[_defenseTargets addObject:target];
|
||||
[_defenseTargets addObject:[target weakRetain]];
|
||||
return YES;
|
||||
}
|
||||
|
||||
|
||||
- (BOOL) isDefenseTarget:(Entity *)target
|
||||
{
|
||||
return [_defenseTargets containsObject:target];
|
||||
return [_defenseTargets containsObject:[target weakRetain]];
|
||||
}
|
||||
|
||||
|
||||
@ -9678,7 +9678,7 @@ Vector positionOffsetForShipInRotationToAlignment(ShipEntity* ship, Quaternion q
|
||||
|
||||
- (void) removeDefenseTarget:(Entity *)target
|
||||
{
|
||||
[_defenseTargets removeObject:target];
|
||||
[_defenseTargets removeObject:[target weakRetain]];
|
||||
}
|
||||
|
||||
|
||||
@ -10178,7 +10178,7 @@ Vector positionOffsetForShipInRotationToAlignment(ShipEntity* ship, Quaternion q
|
||||
{
|
||||
NSEnumerator *targetEnum = [self defenseTargetEnumerator];
|
||||
Entity *target = nil;
|
||||
while ((target = [targetEnum nextObject]))
|
||||
while ((target = [[targetEnum nextObject] weakRefUnderlyingObject]))
|
||||
{
|
||||
if ([target scanClass] == CLASS_NO_DRAW || [(ShipEntity *)target isCloaked] || [target energy] <= 0.0)
|
||||
{
|
||||
@ -11687,6 +11687,15 @@ Vector positionOffsetForShipInRotationToAlignment(ShipEntity* ship, Quaternion q
|
||||
- (void) takeHeatDamage:(double)amount
|
||||
{
|
||||
if ([self status] == STATUS_DEAD) return;
|
||||
|
||||
if ([self isSubEntity])
|
||||
{
|
||||
ShipEntity* owner = [self owner];
|
||||
if (![owner isFrangible])
|
||||
{
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
energy -= amount;
|
||||
throw_sparks = YES;
|
||||
|
@ -504,10 +504,17 @@ static JSBool ShipGetProperty(JSContext *context, JSObject *this, jsid propID, j
|
||||
break;
|
||||
|
||||
case kShip_defenseTargets:
|
||||
result = [entity allDefenseTargets];
|
||||
if (result == nil) result = [NSArray array];
|
||||
{
|
||||
result = [NSMutableArray arrayWithCapacity:[entity defenseTargetCount]];
|
||||
NSEnumerator *defTargets = [entity defenseTargetEnumerator];
|
||||
Entity *target = nil;
|
||||
while ((target = [[defTargets nextObject] weakRefUnderlyingObject]))
|
||||
{
|
||||
[result addObject:target];
|
||||
}
|
||||
break;
|
||||
|
||||
}
|
||||
|
||||
case kShip_escorts:
|
||||
result = [[entity escortGroup] memberArrayExcludingLeader];
|
||||
break;
|
||||
|
Loading…
x
Reference in New Issue
Block a user