Fix bug where subents of stations might themselves be stations
This commit is contained in:
parent
52b6c2b8ab
commit
6469d8ae7b
@ -803,7 +803,7 @@ static ShipEntity *doOctreesCollide(ShipEntity *prime, ShipEntity *other);
|
||||
}
|
||||
else
|
||||
{
|
||||
subentity = [UNIVERSE newShipWithName:subentKey];
|
||||
subentity = [UNIVERSE newSubentityWithName:subentKey];
|
||||
}
|
||||
if (subentity == nil) {
|
||||
OOLog(@"setup.ship.badEntry.subentities",@"Failed to set up entity %@",subentKey);
|
||||
|
@ -722,8 +722,21 @@ NSDictionary *OOMakeDockingInstructions(StationEntity *station, Vector coords, f
|
||||
{
|
||||
return NO;
|
||||
}
|
||||
// and now check for docks
|
||||
|
||||
NSEnumerator *subEnum = nil;
|
||||
|
||||
#ifndef NDEBUG
|
||||
ShipEntity *subEntity = nil;
|
||||
for (subEnum = [self shipSubEntityEnumerator]; (subEntity = [subEnum nextObject]); )
|
||||
{
|
||||
if ([subEntity isStation])
|
||||
{
|
||||
OOLog(@"setup.ship.badType.subentities",@"Subentity %@ (%@) of station %@ is itself a StationEntity. This is an internal error - please report it. ",subEntity,[subEntity shipDataKey],[self displayName]);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
// and now check for docks
|
||||
DockEntity *sub = nil;
|
||||
for (subEnum = [self dockSubEntityEnumerator]; (sub = [subEnum nextObject]); )
|
||||
{
|
||||
@ -1089,7 +1102,7 @@ NSDictionary *OOMakeDockingInstructions(StationEntity *station, Vector coords, f
|
||||
}
|
||||
|
||||
OOLog(@"station.launchShip.failed", @"Cancelled launch for a %@ with role %@, as it is too large for the docking port of the %@.",
|
||||
[ship displayName], [ship primaryRole], [self displayName]);
|
||||
[ship displayName], [ship primaryRole], self);
|
||||
return NO;
|
||||
}
|
||||
|
||||
|
@ -409,9 +409,11 @@ enum
|
||||
- (NSString *) randomShipKeyForRoleRespectingConditions:(NSString *)role;
|
||||
- (ShipEntity *) newShipWithRole:(NSString *)role OO_RETURNS_RETAINED; // Selects ship using role weights, applies auto_ai, respects conditions
|
||||
- (ShipEntity *) newShipWithName:(NSString *)shipKey OO_RETURNS_RETAINED; // Does not apply auto_ai or respect conditions
|
||||
- (ShipEntity *) newSubentityWithName:(NSString *)shipKey OO_RETURNS_RETAINED; // Does not apply auto_ai or respect conditions
|
||||
- (OOVisualEffectEntity *) newVisualEffectWithName:(NSString *)effectKey OO_RETURNS_RETAINED;
|
||||
- (DockEntity *) newDockWithName:(NSString *)shipKey OO_RETURNS_RETAINED; // Does not apply auto_ai or respect conditions
|
||||
- (ShipEntity *) newShipWithName:(NSString *)shipKey usePlayerProxy:(BOOL)usePlayerProxy OO_RETURNS_RETAINED; // If usePlayerProxy, non-carriers are instantiated as ProxyPlayerEntity.
|
||||
- (ShipEntity *) newShipWithName:(NSString *)shipKey usePlayerProxy:(BOOL)usePlayerProxy isSubentity:(BOOL)isSubentity OO_RETURNS_RETAINED;
|
||||
|
||||
- (Class) shipClassForShipDictionary:(NSDictionary *)dict;
|
||||
|
||||
|
@ -2862,7 +2862,19 @@ static BOOL IsFriendlyStationPredicate(Entity *entity, void *parameter)
|
||||
}
|
||||
|
||||
|
||||
- (ShipEntity *) newSubentityWithName:(NSString *)shipKey
|
||||
{
|
||||
return [self newShipWithName:shipKey usePlayerProxy:NO isSubentity:YES];
|
||||
}
|
||||
|
||||
|
||||
- (ShipEntity *) newShipWithName:(NSString *)shipKey usePlayerProxy:(BOOL)usePlayerProxy
|
||||
{
|
||||
return [self newShipWithName:shipKey usePlayerProxy:usePlayerProxy isSubentity:NO];
|
||||
}
|
||||
|
||||
|
||||
- (ShipEntity *) newShipWithName:(NSString *)shipKey usePlayerProxy:(BOOL)usePlayerProxy isSubentity:(BOOL)isSubentity
|
||||
{
|
||||
OOJS_PROFILE_ENTER
|
||||
|
||||
@ -2872,10 +2884,18 @@ static BOOL IsFriendlyStationPredicate(Entity *entity, void *parameter)
|
||||
shipDict = [[OOShipRegistry sharedRegistry] shipInfoForKey:shipKey];
|
||||
if (shipDict == nil) return nil;
|
||||
|
||||
volatile Class shipClass = [self shipClassForShipDictionary:shipDict];
|
||||
if (usePlayerProxy && shipClass == [ShipEntity class])
|
||||
volatile Class shipClass = nil;
|
||||
if (isSubentity)
|
||||
{
|
||||
shipClass = [ProxyPlayerEntity class];
|
||||
shipClass = [ShipEntity class];
|
||||
}
|
||||
else
|
||||
{
|
||||
shipClass = [self shipClassForShipDictionary:shipDict];
|
||||
if (usePlayerProxy && shipClass == [ShipEntity class])
|
||||
{
|
||||
shipClass = [ProxyPlayerEntity class];
|
||||
}
|
||||
}
|
||||
|
||||
@try
|
||||
|
Loading…
x
Reference in New Issue
Block a user