- Fixed bug #17997. When very close to the dock, the player now gets a few extra seconds to finish docking or to back off.

- Fixed a bug where the player got docking clearance while there were still ships in the launch queue.

git-svn-id: http://svn.berlios.de/svnroot/repos/oolite-linux/trunk@4593 127b21dd-08f5-0310-b4b7-95ae10353056
This commit is contained in:
Eric Walch 2011-08-11 16:52:16 +00:00
parent dc9db41bfe
commit 5013d3c330
2 changed files with 31 additions and 12 deletions

View File

@ -731,6 +731,10 @@
(
"Due to an emergency your docking clearance has been revoked. Please clear the station approach immediately."
);
"station-docking-clearance-abort-cancelled-in-f" =
(
"Due to an emergency your docking clearance will be revoked in %.0f seconds. Please clear the station approach immediately."
);
"station-docking-clearance-fined-@-cr" =
(
"You have been fined %@ for unauthorized docking. Docking without asking for clearance is not allowed here.",

View File

@ -263,6 +263,7 @@ static NSDictionary* instructions(int station_id, Vector coords, float speed, fl
{
unsigned i;
NSArray* ships = [shipsOnApproach allKeys];
double playerExtraTime = 0;
no_docking_while_launching = YES;
for (i = 0; i < [ships count]; i++)
@ -278,8 +279,18 @@ static NSDictionary* instructions(int station_id, Vector coords, float speed, fl
if (isDockingStation && [player status] == STATUS_IN_FLIGHT &&
[player getDockingClearanceStatus] >= DOCKING_CLEARANCE_STATUS_REQUESTED)
{
[self sendExpandedMessage:DESC(@"station-docking-clearance-abort-cancelled") toShip:player];
[player setDockingClearanceStatus:DOCKING_CLEARANCE_STATUS_NONE];
if (magnitude2(vector_subtract([player position], [self getPortPosition])) > 2250000) // within 1500m of the dock
{
[self sendExpandedMessage:DESC(@"station-docking-clearance-abort-cancelled") toShip:player];
[player setDockingClearanceStatus:DOCKING_CLEARANCE_STATUS_NONE];
}
else
{
playerExtraTime = 10; // when very close to the port, give the player a few seconds to react on the abort message.
[self sendExpandedMessage:[NSString stringWithFormat:DESC(@"station-docking-clearance-abort-cancelled-in-f"), playerExtraTime ] toShip:player];
[player setDockingClearanceStatus:DOCKING_CLEARANCE_STATUS_TIMING_OUT];
}
}
ships = [shipsOnHold allKeys];
@ -292,7 +303,7 @@ static NSDictionary* instructions(int station_id, Vector coords, float speed, fl
[shipsOnHold removeAllObjects];
[shipAI message:@"DOCKING_COMPLETE"];
last_launch_time = [UNIVERSE getTime];
last_launch_time = [UNIVERSE getTime] + playerExtraTime;
approach_spacing = 0.0;
}
@ -2131,14 +2142,18 @@ static NSDictionary* instructions(int station_id, Vector coords, float speed, fl
switch( [player getDockingClearanceStatus] )
{
case DOCKING_CLEARANCE_STATUS_TIMING_OUT:
last_launch_time = timeNow + DOCKING_CLEARANCE_WINDOW;
[self sendExpandedMessage:[NSString stringWithFormat:
DESC(@"station-docking-clearance-extended-until-@"),
ClockToString([player clockTime] + DOCKING_CLEARANCE_WINDOW, NO)]
toShip:other];
[player setDockingClearanceStatus:DOCKING_CLEARANCE_STATUS_GRANTED];
result = @"DOCKING_CLEARANCE_EXTENDED";
break;
if (!no_docking_while_launching)
{
last_launch_time = timeNow + DOCKING_CLEARANCE_WINDOW;
[self sendExpandedMessage:[NSString stringWithFormat:
DESC(@"station-docking-clearance-extended-until-@"),
ClockToString([player clockTime] + DOCKING_CLEARANCE_WINDOW, NO)]
toShip:other];
[player setDockingClearanceStatus:DOCKING_CLEARANCE_STATUS_GRANTED];
result = @"DOCKING_CLEARANCE_EXTENDED";
break;
}
// else, continue with canceling.
case DOCKING_CLEARANCE_STATUS_REQUESTED:
case DOCKING_CLEARANCE_STATUS_GRANTED:
last_launch_time = timeNow;
@ -2188,7 +2203,7 @@ static NSDictionary* instructions(int station_id, Vector coords, float speed, fl
// No need to set status to REQUESTED as we've already done that earlier.
result = @"DOCKING_CLEARANCE_DENIED_TRAFFIC_INBOUND";
}
if (result == nil && [launchQueue count] && last_launch_time < timeNow)
if (result == nil && [launchQueue count] && no_docking_while_launching)
{
[self sendExpandedMessage:[NSString stringWithFormat:
DESC(@"station-docking-clearance-acknowledged-d-ships-departing"),