aboutsummaryrefslogtreecommitdiff
path: root/advtrains/trainlogic.lua
diff options
context:
space:
mode:
authororwell96 <orwell@bleipb.de>2017-12-18 21:44:36 +0100
committerorwell96 <orwell@bleipb.de>2017-12-18 23:09:23 +0100
commit46c4447da089146c662f217bf3269d78d4c462c2 (patch)
treee846a588b6ddfb03c456b0c3c4d0653cd3402b85 /advtrains/trainlogic.lua
parentfaa60e2bd4d35054f23fda68c06a601f2a197257 (diff)
downloadadvtrains-46c4447da089146c662f217bf3269d78d4c462c2.tar.gz
advtrains-46c4447da089146c662f217bf3269d78d4c462c2.tar.bz2
advtrains-46c4447da089146c662f217bf3269d78d4c462c2.zip
Rewrite rail connection system...
...to support an arbitrary number of connections for rails, which leads to these new features: - switches now get recognized by the trackworker correctly - ability to add real rail crosses During this, I also rewrote the rail registering system and the conway function (important part of path prediction) Note, developers: the track preset format changed, you might need to rewrite them according to the presets in tracks.lua if you wrote your own (possibly breaks advcarts)
Diffstat (limited to 'advtrains/trainlogic.lua')
-rw-r--r--advtrains/trainlogic.lua57
1 files changed, 0 insertions, 57 deletions
diff --git a/advtrains/trainlogic.lua b/advtrains/trainlogic.lua
index d51f1eb..76b0d1d 100644
--- a/advtrains/trainlogic.lua
+++ b/advtrains/trainlogic.lua
@@ -428,63 +428,6 @@ function advtrains.train_step_a(id, train, dtime)
end
end
---about regular: Used by 1. to ensure path gets generated far enough, since end index is not known at this time.
-function advtrains.pathpredict(id, train, regular)
- --TODO duplicate code under 5b.
- local path_pregen=10
-
- local gen_front= path_pregen
- local gen_back= - train.trainlen - path_pregen
- if regular then
- gen_front=math.max(train.index, train.detector_old_index) + path_pregen
- gen_back=math.min(train.end_index, train.detector_old_end_index) - path_pregen
- end
-
- local maxn=train.path_extent_max or 0
- while maxn < gen_front do--pregenerate
- local conway
- if train.max_index_on_track == maxn then
- --atprint("maxn conway for ",maxn,train.path[maxn],maxn-1,train.path[maxn-1])
- conway=advtrains.conway(train.path[maxn], train.path[maxn-1], train.drives_on)
- end
- if conway then
- train.path[maxn+1]=conway
- train.max_index_on_track=maxn+1
- else
- --do as if nothing has happened and preceed with path
- --but do not update max_index_on_track
- atprint("over-generating path max to index ",(maxn+1)," (position ",train.path[maxn]," )")
- train.path[maxn+1]=vector.add(train.path[maxn], vector.subtract(train.path[maxn], train.path[maxn-1]))
- end
- train.path_dist[maxn]=vector.distance(train.path[maxn+1], train.path[maxn])
- maxn=maxn+1
- end
- train.path_extent_max=maxn
-
- local minn=train.path_extent_min or -1
- while minn > gen_back do
- local conway
- if train.min_index_on_track == minn then
- --atprint("minn conway for ",minn,train.path[minn],minn+1,train.path[minn+1])
- conway=advtrains.conway(train.path[minn], train.path[minn+1], train.drives_on)
- end
- if conway then
- train.path[minn-1]=conway
- train.min_index_on_track=minn-1
- else
- --do as if nothing has happened and preceed with path
- --but do not update min_index_on_track
- atprint("over-generating path min to index ",(minn-1)," (position ",train.path[minn]," )")
- train.path[minn-1]=vector.add(train.path[minn], vector.subtract(train.path[minn], train.path[minn+1]))
- end
- train.path_dist[minn-1]=vector.distance(train.path[minn], train.path[minn-1])
- minn=minn-1
- end
- train.path_extent_min=minn
- if not train.min_index_on_track then train.min_index_on_track=-1 end
- if not train.max_index_on_track then train.max_index_on_track=0 end
-end
-
function advtrains.train_step_b(id, train, dtime)