aboutsummaryrefslogtreecommitdiff
path: root/advtrains/nodedb.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/nodedb.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/nodedb.lua')
-rw-r--r--advtrains/nodedb.lua26
1 files changed, 7 insertions, 19 deletions
diff --git a/advtrains/nodedb.lua b/advtrains/nodedb.lua
index 2f014f8..763edbc 100644
--- a/advtrains/nodedb.lua
+++ b/advtrains/nodedb.lua
@@ -132,9 +132,12 @@ function ndb.get_node_raw(pos)
end
-function ndb.swap_node(pos, node)
+function ndb.swap_node(pos, node, no_inval)
minetest.swap_node(pos, node)
ndb.update(pos, node)
+ if not no_inval then
+ advtrains.invalidate_all_paths(pos)
+ end
end
function ndb.update(pos, pnode)
@@ -175,30 +178,15 @@ function advtrains.get_rail_info_at(pos, drives_on)
local rdp=advtrains.round_vector_floor_y(pos)
local node=ndb.get_node_or_nil(rdp)
+ if not node then return end
- --still no node?
- --advtrains.trackdb is nil when there's no data available.
- if not node then
- if advtrains.trackdb then
- --try raildb (see trackdb_legacy.lua)
- local dbe=(advtrains.trackdb[rdp.y] and advtrains.trackdb[rdp.y][rdp.x] and advtrains.trackdb[rdp.y][rdp.x][rdp.z])
- if dbe then
- for tt,_ in pairs(drives_on) do
- if not dbe.tracktype or tt==dbe.tracktype then
- return true, dbe.conn1, dbe.conn2, dbe.rely1 or 0, dbe.rely2 or 0, dbe.railheight or 0
- end
- end
- end
- end
- return nil
- end
local nodename=node.name
if(not advtrains.is_track_and_drives_on(nodename, drives_on)) then
return false
end
- local conn1, conn2, rely1, rely2, railheight, tracktype=advtrains.get_track_connections(node.name, node.param2)
+ local conns, railheight, tracktype=advtrains.get_track_connections(node.name, node.param2)
- return true, conn1, conn2, rely1, rely2, railheight
+ return true, conns, railheight
end
ndb.run_lbm = function(pos, node)