Oolite
Loading...
Searching...
No Matches
StationEntity(OOPrivate) Category Reference

Instance Methods

(void) - pullInShipIfPermitted:
(void) - addShipToStationCount:
(void) - addShipToLaunchQueue:withPriority:
(unsigned) - countOfShipsInLaunchQueueWithPrimaryRole:
(NSDictionary *) - holdPositionInstructionForShip:

Detailed Description

Definition at line 52 of file StationEntity.m.

Method Documentation

◆ addShipToLaunchQueue:withPriority:

- (void) addShipToLaunchQueue: (ShipEntity *) ship
withPriority: (BOOL) priority 

Extends class StationEntity.

Definition at line 936 of file StationEntity.m.

936 :(ShipEntity*)ship withPriority:(BOOL)priority
937{
938 NSEnumerator* subEnum = nil;
939 DockEntity* sub = nil;
940 unsigned threshold = 0;
941
942 // quickest launch if we assign ships to those bays with no incoming ships
943 // and spread the ships evenly around those bays
944 // much easier if the station has at least one launch-only dock
945 while (threshold < 16) {
946 for (subEnum = [self dockSubEntityEnumerator]; (sub = [subEnum nextObject]);) {
947 if (sub != player_reserved_dock) {
948 if ([sub countOfShipsInDockingQueue] == 0) {
949 if ([sub allowsLaunching] && [sub countOfShipsInLaunchQueue] <= threshold) {
950 if ([sub allowsLaunchingOf:ship]) {
951 [sub addShipToLaunchQueue:ship withPriority:priority];
952 return;
953 }
954 }
955 }
956 }
957 }
958 threshold++;
959 }
960 // if we get this far, all docks have at least some incoming traffic.
961 // usually most efficient (since launching is far faster than docking)
962 // to assign all ships to the *same* dock with the smallest incoming queue
963 // rather than to try spreading them out across several queues
964 // also stops escorts being launched before their mothership
965 threshold = 0;
966 while (threshold < 16) {
967 for (subEnum = [self dockSubEntityEnumerator]; (sub = [subEnum nextObject]);) {
968 /* so this time as long as it allows launching only check
969 * the docking queue size so long as enumerator order is
970 * deterministic, this will assign every launch this
971 * update to the same dock (edge case where new docking
972 * ship appears in the middle, probably not a problem) */
973 if ([sub allowsLaunching] && [sub countOfShipsInDockingQueue] <= threshold) {
974 if ([sub allowsLaunchingOf:ship]) {
975 [sub addShipToLaunchQueue:ship withPriority:priority];
976 return;
977 }
978 }
979 }
980 threshold++;
981 }
982
983 OOLog(@"station.launchShip.failed", @"Cancelled launch for a %@ with role %@, as the %@ has too many ships in its launch queue(s) or no suitable launch docks.",
984 [ship displayName], [ship primaryRole], [self displayName]);
985}
#define OOLog(class, format,...)
Definition OOLogging.h:84
return nil
void addShipToLaunchQueue:withPriority:(ShipEntity *ship,[withPriority] BOOL priority)
Definition DockEntity.m:785

References DockEntity::addShipToLaunchQueue:withPriority:, nil, and OOLog.

Referenced by StationEntity::launchDefenseShip, StationEntity::launchEscort, StationEntity::launchIndependentShip:, StationEntity::launchMiner, StationEntity::launchPatrol, StationEntity::launchPirateShip, StationEntity::launchPolice, StationEntity::launchScavenger, StationEntity::launchShipWithRole:, and StationEntity::launchShuttle.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ addShipToStationCount:

- (void) addShipToStationCount: (ShipEntity *) ship

Extends class StationEntity.

Definition at line 1068 of file StationEntity.m.

1068 :(ShipEntity*)ship
1069{
1070 if ([ship isShuttle])
1071 docked_shuttles++;
1072 else if ([ship isTrader] && ![ship isPlayer])
1073 docked_traders++;
1074 else if (([ship isPolice] && ![ship isEscort]) || [ship hasPrimaryRole:@"defense_ship"]) {
1075 if (0 < defenders_launched)
1076 defenders_launched--;
1077 } else if ([ship hasPrimaryRole:@"scavenger"] || [ship hasPrimaryRole:@"miner"]) // treat miners and scavengers alike!
1078 {
1079 if (0 < scavengers_launched)
1080 scavengers_launched--;
1081 }
1082}

Referenced by StationEntity::noteDockedShip:.

Here is the caller graph for this function:

◆ countOfShipsInLaunchQueueWithPrimaryRole:

- (unsigned) countOfShipsInLaunchQueueWithPrimaryRole: (NSString *) role

Extends class StationEntity.

Definition at line 987 of file StationEntity.m.

987 :(NSString*)role
988{
989 unsigned result = 0;
990 NSEnumerator* subEnum = nil;
991 DockEntity* sub = nil;
992 for (subEnum = [self dockSubEntityEnumerator]; (sub = [subEnum nextObject]);) {
993 result += [sub countOfShipsInLaunchQueueWithPrimaryRole:role];
994 }
995 return result;
996}

References DockEntity::countOfShipsInLaunchQueueWithPrimaryRole:, and nil.

Referenced by StationEntity::launchMiner, and StationEntity::launchScavenger.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ holdPositionInstructionForShip:

- (NSDictionary *) holdPositionInstructionForShip: (ShipEntity *) ship

Extends class StationEntity.

Definition at line 506 of file StationEntity.m.

506 :(ShipEntity*)ship
507{
508 if (![_shipsOnHold containsObject:ship]) {
509 [self sendExpandedMessage:@"[station-acknowledges-hold-position]" toShip:ship];
510 [_shipsOnHold addObject:ship];
511 }
512
513 return OOMakeDockingInstructions(self, [ship position], 0, 100, @"HOLD_POSITION", nil, NO, -1);
514}
NSDictionary * OOMakeDockingInstructions(StationEntity *station, HPVector coords, float speed, float range, NSString *ai_message, NSString *comms_message, BOOL match_rotation, int docking_stage)

References nil, OOMakeDockingInstructions(), and ShipEntity::sendExpandedMessage:toShip:.

Referenced by StationEntity::dockingInstructionsForShip:.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ pullInShipIfPermitted:

- (void) pullInShipIfPermitted: (ShipEntity *) ship

Extends class StationEntity.

Definition at line 720 of file StationEntity.m.

720 :(ShipEntity*)ship
721{
722 [ship enterDock:self]; // dock performs permitted checks
723}
void enterDock:(StationEntity *station)

References ShipEntity::enterDock:.

Referenced by StationEntity::autoDockShipsOnHold.

Here is the call graph for this function:
Here is the caller graph for this function:

The documentation for this category was generated from the following file: