aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authororwell96 <orwell@bleipb.de>2020-07-26 18:53:16 +0200
committerorwell96 <orwell@bleipb.de>2020-07-26 18:53:16 +0200
commit00031064a5ef66306fe49eb7ee5fa6dfe1454238 (patch)
tree540532e59a88d61a9f5464186ddae39c5ce24a48
parentd65ba80df77432849b3cf852619706632a4e4408 (diff)
downloadadvtrains-00031064a5ef66306fe49eb7ee5fa6dfe1454238.tar.gz
advtrains-00031064a5ef66306fe49eb7ee5fa6dfe1454238.tar.bz2
advtrains-00031064a5ef66306fe49eb7ee5fa6dfe1454238.zip
Do not unload wagons when a player that is logged in sits in itrelease-2.1.3
-rw-r--r--advtrains/wagons.lua25
1 files changed, 18 insertions, 7 deletions
diff --git a/advtrains/wagons.lua b/advtrains/wagons.lua
index ba746ef..95582d0 100644
--- a/advtrains/wagons.lua
+++ b/advtrains/wagons.lua
@@ -486,15 +486,26 @@ function wagon:on_step(dtime)
-- unload entity if out of range (because relevant pr won't be merged in engine)
-- This is a WORKAROUND!
- local outofrange = true
- for _,p in pairs(minetest.get_connected_players()) do
- if vector.distance(p:get_pos(),pos)<=unload_wgn_range then
- outofrange = false
+ local players_in = false
+ for sno,pname in pairs(data.seatp) do
+ if minetest.get_player_by_name(pname) then
+ -- Fix: If the RTT is too high, a wagon might be recognized out of range even if a player sits in it
+ -- (client updates position not fast enough)
+ players_in = true
+ break
end
end
- if outofrange then
- --atdebug("wagon",self.id,"unloading (too far away)")
- self.object:remove()
+ if not players_in then
+ local outofrange = true
+ for _,p in pairs(minetest.get_connected_players()) do
+ if vector.distance(p:get_pos(),pos)<=unload_wgn_range then
+ outofrange = false
+ end
+ end
+ if outofrange then
+ --atdebug("wagon",self.id,"unloading (too far away)")
+ self.object:remove()
+ end
end
end