Deal with permanent and temporary rejects from docking in correct order for multidock vessels
git-svn-id: http://svn.berlios.de/svnroot/repos/oolite-linux/trunk@5079 127b21dd-08f5-0310-b4b7-95ae10353056
This commit is contained in:
parent
6a52ff134f
commit
cbabc68986
@ -179,14 +179,23 @@ MA 02110-1301, USA.
|
|||||||
|
|
||||||
- (NSString*) canAcceptShipForDocking:(ShipEntity *) ship
|
- (NSString*) canAcceptShipForDocking:(ShipEntity *) ship
|
||||||
{
|
{
|
||||||
|
// First test permanent rejection reasons
|
||||||
if (!allow_docking && (![ship isPlayer] || !allow_player_docking))
|
if (!allow_docking && (![ship isPlayer] || !allow_player_docking))
|
||||||
{
|
{
|
||||||
return @"TRY_AGAIN_LATER";
|
return @"TOO_BIG_TO_DOCK"; // not strictly true, but is the permanent-reject code
|
||||||
}
|
}
|
||||||
if (!allow_player_docking && [ship isPlayer])
|
if (!allow_player_docking && [ship isPlayer])
|
||||||
{
|
{
|
||||||
return @"TRY_AGAIN_LATER";
|
return @"TOO_BIG_TO_DOCK"; // not strictly true, but is the permanent-reject code
|
||||||
}
|
}
|
||||||
|
BoundingBox bb = [ship totalBoundingBox];
|
||||||
|
if ((port_dimensions.x < (bb.max.x - bb.min.x) || port_dimensions.y < (bb.max.y - bb.min.y)) &&
|
||||||
|
(port_dimensions.y < (bb.max.x - bb.min.x) || port_dimensions.x < (bb.max.y - bb.min.y)))
|
||||||
|
{
|
||||||
|
return @"TOO_BIG_TO_DOCK";
|
||||||
|
}
|
||||||
|
|
||||||
|
// Second test temporary rejection reasons
|
||||||
if (no_docking_while_launching)
|
if (no_docking_while_launching)
|
||||||
{
|
{
|
||||||
return @"TRY_AGAIN_LATER";
|
return @"TRY_AGAIN_LATER";
|
||||||
@ -196,12 +205,6 @@ MA 02110-1301, USA.
|
|||||||
{
|
{
|
||||||
return @"TRY_AGAIN_LATER";
|
return @"TRY_AGAIN_LATER";
|
||||||
}
|
}
|
||||||
BoundingBox bb = [ship totalBoundingBox];
|
|
||||||
if ((port_dimensions.x < (bb.max.x - bb.min.x) || port_dimensions.y < (bb.max.y - bb.min.y)) &&
|
|
||||||
(port_dimensions.y < (bb.max.x - bb.min.x) || port_dimensions.x < (bb.max.y - bb.min.y)))
|
|
||||||
{
|
|
||||||
return @"TOO_BIG_TO_DOCK";
|
|
||||||
}
|
|
||||||
|
|
||||||
return @"DOCKING_POSSIBLE";
|
return @"DOCKING_POSSIBLE";
|
||||||
}
|
}
|
||||||
|
@ -381,8 +381,8 @@ NSDictionary *OOMakeDockingInstructions(StationEntity *station, Vector coords, f
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// this routine does more than set coordinates - it provides a whole set of docking instructions and messages at each stage..
|
// this routine does initial traffic control, before passing the ship
|
||||||
//
|
// to an appropriate dock for docking coordinates and instructions
|
||||||
- (NSDictionary *) dockingInstructionsForShip:(ShipEntity *) ship
|
- (NSDictionary *) dockingInstructionsForShip:(ShipEntity *) ship
|
||||||
{
|
{
|
||||||
if (ship == nil) return nil;
|
if (ship == nil) return nil;
|
||||||
@ -412,11 +412,13 @@ NSDictionary *OOMakeDockingInstructions(StationEntity *station, Vector coords, f
|
|||||||
DockEntity *sub = nil;
|
DockEntity *sub = nil;
|
||||||
unsigned queue = 100;
|
unsigned queue = 100;
|
||||||
|
|
||||||
|
BOOL alldockstoosmall = YES;
|
||||||
for (subEnum = [self dockSubEntityEnumerator]; (sub = [subEnum nextObject]); )
|
for (subEnum = [self dockSubEntityEnumerator]; (sub = [subEnum nextObject]); )
|
||||||
{
|
{
|
||||||
if ([sub shipIsInDockingQueue:ship])
|
if ([sub shipIsInDockingQueue:ship])
|
||||||
{ // if already claimed a docking queue, use that one
|
{ // if already claimed a docking queue, use that one
|
||||||
chosenDock = sub;
|
chosenDock = sub;
|
||||||
|
alldockstoosmall = NO;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if (sub != player_reserved_dock)
|
if (sub != player_reserved_dock)
|
||||||
@ -426,11 +428,26 @@ NSDictionary *OOMakeDockingInstructions(StationEntity *station, Vector coords, f
|
|||||||
// try to select the dock with the fewest ships already enqueued
|
// try to select the dock with the fewest ships already enqueued
|
||||||
chosenDock = sub;
|
chosenDock = sub;
|
||||||
queue = [sub countOfShipsInDockingQueue];
|
queue = [sub countOfShipsInDockingQueue];
|
||||||
|
alldockstoosmall = NO;
|
||||||
}
|
}
|
||||||
|
else if (![docking isEqualToString:@"TOO_BIG_TO_DOCK"])
|
||||||
|
{
|
||||||
|
alldockstoosmall = NO;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
alldockstoosmall = NO;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (chosenDock == nil)
|
if (chosenDock == nil)
|
||||||
{
|
{
|
||||||
|
if ([docking isEqualToString:@"TOO_BIG_TO_DOCK"] && !alldockstoosmall)
|
||||||
|
{
|
||||||
|
// last dock was too small, but there may be an acceptable one
|
||||||
|
// not tested yet or returning TRY_AGAIN_LATER
|
||||||
|
docking = @"TRY_AGAIN_LATER";
|
||||||
|
}
|
||||||
// no docks accept this ship (or the player is blocking them)
|
// no docks accept this ship (or the player is blocking them)
|
||||||
return OOMakeDockingInstructions(self, [ship position], 0, 100, docking, nil, NO);
|
return OOMakeDockingInstructions(self, [ship position], 0, 100, docking, nil, NO);
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user