aboutsummaryrefslogtreecommitdiff
path: root/advtrains_interlocking
ModeNameSize
-rw-r--r--database.lua18582logplain
-rw-r--r--demosignals.lua2656logplain
-rw-r--r--depends.txt9logplain
-rw-r--r--init.lua778logplain
-rw-r--r--lzb.lua6882logplain
d---------models46logplain
-rw-r--r--route_prog.lua17572logplain
-rw-r--r--routesetting.lua10105logplain
-rw-r--r--signal_api.lua17323logplain
-rw-r--r--tcb_ts_ui.lua23434logplain
d---------textures1050logplain
-rw-r--r--tool.lua1932logplain
-rw-r--r--train_sections.lua5320logplain
an> So, the occupation is a reverse lookup of paths. Then, a callback system will handle changes in those indices, as follows: Whenever the train generates new path items (path_get/path_create), their counterpart indices will be filled in here. Whenever a path gets invalidated or path items are deleted, their index counterpart is erased from here. When a train needs to know whether a position is blocked by another train, it will (and is permitted to) query the train.index and train.end_index and compare them to the blocked position's index. Callback system for 3rd-party path checkers: advtrains.te_register_on_new_path(func(id, train)) -- Called when a train's path is re-initalized, either when it was invalidated -- or the saves were just loaded -- It can be assumed that everything is in the state of when the last run -- of on_update was made, but all indices are shifted by an unknown amount. advtrains.te_register_on_update(func(id, train)) -- Called each step and after a train moved, its length changed or some other event occured -- The path is unmodified, and train.index and train.end_index can be reliably -- queried for the new position and length of the train. -- note that this function might be called multiple times per step, and this -- function being called does not necessarily mean that something has changed. -- It is ensured that on_new_path callbacks are executed prior to these callbacks whenever -- an invalidation or a reload occured. advtrains.te_register_on_create(func(id, train)) -- Called right after a train is created, right after the initial new_path callback advtrains.te_register_on_remove(func(id, train)) -- Called right before a train is deleted All callbacks are allowed to save certain values inside the train table, but they must ensure that