diff options
author | orwell96 <orwell@bleipb.de> | 2019-01-22 12:26:31 +0100 |
---|---|---|
committer | orwell96 <orwell@bleipb.de> | 2019-01-22 12:26:31 +0100 |
commit | 240e7dd091c6c66ae6cdade3d9f4099756f60916 (patch) | |
tree | 10284f47875748d9c7047992731ad143a6f34e14 /advtrains/path.lua | |
parent | e2ae763dba3f7f609eccd9b8dd378304fad24b0d (diff) | |
download | advtrains-240e7dd091c6c66ae6cdade3d9f4099756f60916.tar.gz advtrains-240e7dd091c6c66ae6cdade3d9f4099756f60916.tar.bz2 advtrains-240e7dd091c6c66ae6cdade3d9f4099756f60916.zip |
Warn when something clears the path winthin train step
Diffstat (limited to 'advtrains/path.lua')
-rw-r--r-- | advtrains/path.lua | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/advtrains/path.lua b/advtrains/path.lua index a0bcd04..64e0d1c 100644 --- a/advtrains/path.lua +++ b/advtrains/path.lua @@ -98,7 +98,15 @@ end -- Invalidates a path -- this is supposed to clear stuff from the occupation tables -function advtrains.path_invalidate(train) +-- This function throws a warning whenever any code calls it while the train steps are run, since that must not happen. +-- The ignore_lock parameter can be used to ignore this, however, it should then be accompanied by a call to train_ensure_init +-- before returning from the calling function. +function advtrains.path_invalidate(train, ignore_lock) + if advtrains.lock_path_inval and not ignore_lock then + atwarn("Train ",train.train_id,": Illegal path invalidation has occured during train step:") + atwarn(debug.traceback()) + end + if train.path then for i,p in pairs(train.path) do advtrains.occ.clear_item(train.id, advtrains.round_vector_floor_y(p)) @@ -122,11 +130,11 @@ end -- Prints a path using the passed print function -- This function should be 'atprint', 'atlog', 'atwarn' or 'atdebug', because it needs to use print_concat_table function advtrains.path_print(train, printf) + printf("path_print: tid =",train.train_id," index =",train.index," end_index =",train.end_index," vel =",train.velocity) if not train.path then printf("path_print: Path is invalidated/inexistant.") return end - printf("path_print: tid =",train.train_id," index =",train.index," end_index =",train.end_index," vel =",train.velocity) printf("i: CP Position Dir CN ->Dist->") for i = train.path_ext_b, train.path_ext_f do if i==train.path_trk_b then |