aboutsummaryrefslogtreecommitdiff
path: root/advtrains
diff options
context:
space:
mode:
authororwell96 <orwell@bleipb.de>2017-11-22 23:13:42 +0100
committerorwell96 <orwell@bleipb.de>2017-11-22 23:13:42 +0100
commit5fc6cc7f5b7125e470e0e24e4da639f868476dc3 (patch)
tree7fbed8c33be42892340bad9bf99481f6df39852e /advtrains
parent2d4833b5a8d3555c257cbeb5928c32eb36caa473 (diff)
downloadadvtrains-5fc6cc7f5b7125e470e0e24e4da639f868476dc3.tar.gz
advtrains-5fc6cc7f5b7125e470e0e24e4da639f868476dc3.tar.bz2
advtrains-5fc6cc7f5b7125e470e0e24e4da639f868476dc3.zip
Fix multiple track types not working simultaneously
Bug was caused by the drives_on table of every train and advtrains.all_tracktypes sharing the same reference, which caused advtrains.all_tracktypes to become the intersection of all train drives_on's in the world. However, this did become empty, causing nothing to work anymore.
Diffstat (limited to 'advtrains')
-rw-r--r--advtrains/tracks.lua10
-rw-r--r--advtrains/trainlogic.lua4
2 files changed, 12 insertions, 2 deletions
diff --git a/advtrains/tracks.lua b/advtrains/tracks.lua
index bfa95fe..1cbbc0b 100644
--- a/advtrains/tracks.lua
+++ b/advtrains/tracks.lua
@@ -408,11 +408,19 @@ end
function advtrains.is_track_and_drives_on(nodename, drives_on_p)
+ local drives_on = drives_on_p
+ if not drives_on then drives_on = advtrains.all_tracktypes end
+ local hasentry = false
+ for _,_ in pairs(drives_on) do
+ hasentry=true
+ end
+ if not hasentry then drives_on = advtrains.all_tracktypes end
+
if not minetest.registered_nodes[nodename] then
return false
end
local nodedef=minetest.registered_nodes[nodename]
- for k,v in pairs(drives_on_p) do
+ for k,v in pairs(drives_on) do
if nodedef.groups["advtrains_track_"..k] then
return true
end
diff --git a/advtrains/trainlogic.lua b/advtrains/trainlogic.lua
index c158ebe..cd5017b 100644
--- a/advtrains/trainlogic.lua
+++ b/advtrains/trainlogic.lua
@@ -576,6 +576,7 @@ function advtrains.train_step_b(id, train, dtime)
end
--- 8b damage players ---
if not minetest.settings:get_bool("creative_mode") then
+ local testpts = minetest.pos_to_string(testpos)
local player=advtrains.playersbypts[testpts]
if player and not minetest.check_player_privs(player, "creative") and train.velocity>3 then
--instantly kill player
@@ -644,7 +645,8 @@ function advtrains.add_wagon_to_train(wagon, train_id, index)
end
function advtrains.update_trainpart_properties(train_id, invert_flipstate)
local train=advtrains.trains[train_id]
- train.drives_on=advtrains.all_tracktypes
+ train.drives_on=advtrains.merge_tables(advtrains.all_tracktypes)
+ --FIX: deep-copy the table!!!
train.max_speed=20
local rel_pos=0
local count_l=0