Code review comment for lp:~widelands-dev/widelands/ferry

Revision history for this message
Benedikt Straub (nordfriese) wrote :

Whether waterways/ferries are enabled can be checked as
  map.get_waterway_max_length() >= 2
Typically, they are enabled only on maps where they make sense. Waterways have a maximum length that is map-dependent.
If two flags can be connected both by a new road and by a new waterway, the AI should build a waterway only if a road connection is much much longer. Building waterways if a road is also possible nearby makes sense in a handful of corner cases but not in the majority of cases.
Also, if there are two flags with the same ware economy but different worker economies, the AI should try very hard to connect them with a normal road if somehow possible.

> It would be nice if the ferries were per economy

Completely impossible, sorry. A ferry can be sent to any waterway that is in the same FerryFleet as itself – and there can be multiple economies adjacent to the same ocean (not to mention that each economy can be adjacent to multiple oceans). Per-economy distribution (or bookkeeping) of ferries is just not possible.

> and AI would know in advance if the waterroad will be supplied by a ferry immediately

You could either
– Build the waterway; some 10 seconds later query its fleet whether a ferry is coming, and if not, destroy the new waterway and remember not to retry for some time.
– Or if you really want to check before you build a waterway: Check out FerryFleet::find_other_fleet, and copy the pathfinding code from there to obtain the ferryfleet that belongs to the ocean you are interested in; then you can query that fleet for unoccupied ferries.

« Back to merge proposal