First, cargo distribution is enabled per set of cargo types, globally for all companies. Eg. it is in the control of the human person playing with your AI. There is a new method AICargo.GetDistributionType(cargo_type) which you can use to check if a given cargo type uses non-manual distribution. This is probably easier to use than reading the settings by hand in most cases.
When cargo distribution is non-manual (asymmetric or symmetric), and you give cargo the option to make choices in where to be transported, you get the problem that you will want to analyze where cargo goes. This is where the new APIs come in. (It is also possible to stick your head into the sand and always force cargo to only have one choice (by use of order modifiers) and ignore cargo distribution even if it has been enabled)
New APIs
- AICargo.GetDistributionType(cargo_type)
- AIStation.GetCargoWaitingFrom(station_id, from_station_id, cargo_id)
- AIStation.GetCargoWaitingVia(station_id, via_station_id, cargo_id)
Both also accept STATION_INVALID as from/via station id. This give you the red "any station" numbers displayed in GUI.
The reason why there is no GetCargoWaitingTo is that a such value would only be an estimate based on planned values from CargoDist. You can find further API design discussion on the IRC log of #openttd.dev: 9 March and 10 March. (note that my link to the work-in-progress patch now shows the final version of the patch)
Use case - PAXLink
I have updated my AI PAXLink (not yet released), so that when cargodist is enabled, it omit the order modifers (transfer, leave empty etc.) and instead let cargo find their way. Using GetCargoWaitingVia, I can filter the passengers waiting at my airports for passengers heading to the other town which is what I want to use as input to decide if I need more/fewer aircraft. Passengers waiting to travel locally is used as input to the decision making if more/fewer local buses are wanted.
Game scripts
All the three new API methods are also available to Game Scripts if anyone find use for them in that context.