diff options
author | orwell96 <orwell@bleipb.de> | 2020-07-26 18:53:16 +0200 |
---|---|---|
committer | orwell96 <orwell@bleipb.de> | 2020-07-26 18:53:16 +0200 |
commit | 00031064a5ef66306fe49eb7ee5fa6dfe1454238 (patch) | |
tree | 540532e59a88d61a9f5464186ddae39c5ce24a48 | |
parent | d65ba80df77432849b3cf852619706632a4e4408 (diff) | |
download | advtrains-release-2.1.3.tar.gz advtrains-release-2.1.3.tar.bz2 advtrains-release-2.1.3.zip |
Do not unload wagons when a player that is logged in sits in itrelease-2.1.3
-rw-r--r-- | advtrains/wagons.lua | 25 |
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
|