News:

Simutrans Sites
Know our official sites. Find tools and resources for Simutrans.

get_successors(): none?

Started by jameskuyper, November 29, 2022, 06:58:52 AM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

jameskuyper

As I understand it, in a vehicle's *.dat file:
1. If any of a vehicle's Constraint[Next] values is "none", the vehicle is permitted to have no vehicles behind it.
2. If the only Constraint[Next] values is "none", the vehicle is required to have no vehicles behind it.
3. If there are no Constraint[Next] values, the vehicle may be followed by any vehicle whose Constraint[Prev] values allow it.
As far as I can tell from my experiments, the last two cases both result in vehicle_desc_x.get_successors() returning an empty list. How may I distinguish them?

Dwachs

In case (2) the returned list should not be empty but contain a null element.

I have to check this.

Edit: it does not. The null element is explicitly thrown away.
Parsley, sage, rosemary, and maggikraut.

jameskuyper

Hypothesis: can_be_last() tests whether any of Constraint[Next] was "none". Therefore:

get_successors() non-empty, can_be_last() false: must be one of the items on the list.
get_successors() non-empty, can_be_last() true: can be one of the items on the list, or no successor at all.
get_successors() empty, can_be_last() false: can be any vehicle whose one predecessor list allows it.
get_successors() empty, can_be_last() true: must be last.

This seems to be consistent with the cases I checked. Is it correct?

Dwachs

Looks correct. Then the docs are wrong: if the list is empty and can_be_last is true then it has to be the last vehicle.
Parsley, sage, rosemary, and maggikraut.