Extra consistency checks to attempt to avoid "ERROR: status is STATUS_DEAD, not STATUS_DOCKED, but dockedStation is not nil" - player can't dock normally while dead, and player can't be destroyed while docked.

git-svn-id: http://svn.berlios.de/svnroot/repos/oolite-linux/trunk@3315 127b21dd-08f5-0310-b4b7-95ae10353056
This commit is contained in:
Jens Ayton 2010-05-10 18:41:22 +00:00
parent 084248f98f
commit efd5097efa
2 changed files with 6 additions and 5 deletions

View File

@ -4014,6 +4014,7 @@ static GLfloat launchRoll;
- (void) getDestroyedBy:(Entity *)whom context:(NSString *)why - (void) getDestroyedBy:(Entity *)whom context:(NSString *)why
{ {
if ([self isDocked]) return; // Can't die while docked. (Doing so would cause breakage elsewhere.)
OOLog(@"player.ship.damage", @"Player destroyed by %@ due to %@", whom, why); OOLog(@"player.ship.damage", @"Player destroyed by %@ due to %@", whom, why);
NSString *scoreMS = [NSString stringWithFormat:DESC(@"gameoverscreen-score-@-f"), NSString *scoreMS = [NSString stringWithFormat:DESC(@"gameoverscreen-score-@-f"),

View File

@ -302,7 +302,7 @@ static NSDictionary* instructions(int station_id, Vector coords, float speed, fl
NSArray* ships = [shipsOnApproach allKeys]; NSArray* ships = [shipsOnApproach allKeys];
for (i = 0; i < [ships count]; i++) for (i = 0; i < [ships count]; i++)
{ {
int sid = [(NSString *)[ships objectAtIndex:i] intValue]; int sid = [ships oo_intAtIndex:i];
if ([UNIVERSE entityForUniversalID:sid]) if ([UNIVERSE entityForUniversalID:sid])
[[UNIVERSE entityForUniversalID:sid] enterDock:self]; [[UNIVERSE entityForUniversalID:sid] enterDock:self];
} }
@ -311,7 +311,7 @@ static NSDictionary* instructions(int station_id, Vector coords, float speed, fl
ships = [shipsOnHold allKeys]; ships = [shipsOnHold allKeys];
for (i = 0; i < [ships count]; i++) for (i = 0; i < [ships count]; i++)
{ {
int sid = [(NSString *)[ships objectAtIndex:i] intValue]; int sid = [ships oo_intAtIndex:i];
if ([UNIVERSE entityForUniversalID:sid]) if ([UNIVERSE entityForUniversalID:sid])
[[UNIVERSE entityForUniversalID:sid] enterDock:self]; [[UNIVERSE entityForUniversalID:sid] enterDock:self];
} }
@ -853,10 +853,10 @@ static NSDictionary* instructions(int station_id, Vector coords, float speed, fl
} }
- (BOOL) shipIsInDockingCorridor:(ShipEntity*) ship - (BOOL) shipIsInDockingCorridor:(ShipEntity *)ship
{ {
if ((!ship)||(!ship->isShip)) if (!ship || ![ship isShip]) return NO;
return NO; if ([ship isPlayer] && [ship status] == STATUS_DEAD) return NO;
Quaternion q0 = quaternion_multiply(port_orientation, orientation); Quaternion q0 = quaternion_multiply(port_orientation, orientation);
Vector vi = vector_right_from_quaternion(q0); Vector vi = vector_right_from_quaternion(q0);