Parking assignment

From FSDeveloper Wiki
Jump to: navigation, search



Introduction

In order to find a parking spot FSX will scan through all parking spots at the given airport.

For each parking it will check if it is occupied and skip it if it is already assigned.

It will also retrieve the wingspan of the plane, divide it by two and use the next largest integer value to determine if the parking is large enough. For example: wing span = 32.9 meters, 32.9 divided by two is 16.45, FSX will check if the radius of the parking is 17 meters or larger. Parking spots that are too small will be skipped. [TODO: what value is used for vehicles / planes without wingspan specified]

If the parking is available and large enough it will call the scoring function. In the end the parking with the smallest score will be selected.

The scoring function itself takes several inputs: the requested parking name, the requested parking types, the requested radius, the requested ICAO codes and a flag that indicates whether the request is for a user or AI plane.

Scoring

In the scoring function 4 individual scores will be determined for: radius, name, type and ICAO.

Radius

The requested radius is subtracted from the actual radius. The smaller the result, the more likely the parking will be selected. FSX thus looks for a parking that is just large enough. An additional check is performed and I'm not sure what is done exactly. The parking is checked for the presence of a subobject and if one is found the score will be increased by one. One possibility is that this is the check for a jetway, in the scenery or actually on display for the current settings. I'm not sure, since this will mean that for two otherwise equal parkings the one without a jetway will be selected.

The resulting score is then limited to the range 0..255.

Parking Name

The requested parking name appears to be limited to PARKING, GATE, DOCK and NONE. The parking name of the parking currently being evaluated is retrieved. If the request is NONE or above the maximum definded parking name (25 = GATE_Z) the score will be 0. A score of 0 is also assigned if there is an exact match between the request and the actual name.

If not, which is in most cases (eg. request: GATE actual: GATE_D), the following will happen:

  • If the request is DOCK:
    • The function will return immediately with all four individual scores at 255.
  • If the request is PARKING:
    • If the actual name is NONE or GATE, DOCK, GATE_... the score will be 10
    • If the actual name is PARKING the score will be 0
    • Else the score will be 1 (actual name is N_PARKING, NE_PARKING, ....)
  • If the request is GATE:
    • If the actual name is GATE or GATE_....: for an exact match the score will be 0, else it will be 1. SO if the actual is GATE_K and the request is GATE_K, the score will be 0. But as mentioned before, I'm not sure if there ever will be a specific gate request.
    • Else the score will be 10 (DOCK, all PARKING names)

Parking Type

This is where it gets a bit tricky. Again, the actual value is compared to the requested value. If no types are in the request the score will be 0, unless the actual type is VEHICLE, then the function will return all 255's.

If there are requests the actual type will be compared to each of them, if a match is found the score will be the index of the match (0 based). This implies that the order of codes entered in the aircraft.cfg is important. (As mentioned in the SDK).

If no match is found the first listed type will be used for further evaluation.

The different types that are evaluated are: RAMP, CARGO, MIL_CARGO, MIL_COMBAT, GATE, DOCK, VEHICLE, FUEL [not 100% sure, but VEHICLE is the highest value from the SDK and in the code an additional one is checked which I assume to be FUEL]. (Remember that exact matches were already taken care of with a score of 0)

request / actual: ramp cargo mil_cargo mil_combat gate dock vehicle fuel
ramp 0 2 4 5 3 10 10 10
cargo 1 0 3 4 2 10 10 10
mil_cargo 2 3 0 1 4 10 10 10
mil_combat 2 3 1 0 4 10 10 10
gate 3 2 4 5 0 10 10 10
dock all four scores will be 255
vehicle all four scores will be 255 0 4x255
Scores for actual parking type versus requested parking type, lower is better

ICAO Code

For the ICAO code two lists will be matched, the list of codes for the parking and that for the plane.

If no codes are present in the request (as in: no codes in the aircraft.cfg):

  • If the parking has no codes the score will be 0.
  • If the parking has codes the score will be 255.

If the request has codes:

  • If the parking has no codes, the score will be 254.
  • If the parking has codes the lists will be matched. The score will depend on the indices of the match: 2 * index of match in list of parking codes + 1 * index of match in list of plane codes.

[TODO: What is the score if there is no match, I guess at least 253] [TODO: Which list is in the outerloop? Are all the plane codes checked vs the first parking code and then the second, or are all the parking codes checked vs the first plane code.]

Combining the scores for AI

At this point there will be four individual scores 0..255. For an AI request these will be combined to a single unsigned integer in this sequence: ICAO, Type, Name, Radius. In other words for AI the ICAO matching is most important. If several parkings give the same score for the ICAO code, the requested type will determine which one is assigned. If there are still parkings with an equal score, the parking name will decide. [TODO: What determines the requested name, is it always GATE, it is not controlled by the aircraft.cfg] If there are still multiple options available, the smallest parking will be assigned. Possibly, if there are several that are the smallest precedence might be given to one without a jetway [Unconfirmed].

If the score for several parkings is completely identical, the first one encountered will be selected. This can still vary as the function that scans through the parkings does not start the scan at index 0, but somewhere in the middle and then wraps around. [TODO: What determines the first parking evaluated: random, last parking found?]

Combining the scores for the user plane

The same scores are used, but the order in which they are evaluated differs. In this case the parking name is most important. This ofcourse is because the user actually selects a specific parking name (GATE, PARKING) from the ATC menu. Next the type is taken in to account and then the ICAO code. The ICAO code thus has a much lower weight for the user plane. Again, the final score that is evaluated is the radius, the smallest fitting parking will be assigned.


Related

Internal

External