diff options
author | cheapie <no-email-for-you@example.com> | 2025-03-22 21:55:38 -0500 |
---|---|---|
committer | cheapie <no-email-for-you@example.com> | 2025-03-22 21:55:38 -0500 |
commit | 2a2d7f18755845e2c68f872918261f4526d3cafb (patch) | |
tree | 2ef4b2497af351e2674b612e7c84e05fa8d78c95 /drive_entity.lua | |
parent | 690374449d39aefe995c380b951aecdd18374ef3 (diff) | |
download | celevator-2a2d7f18755845e2c68f872918261f4526d3cafb.tar celevator-2a2d7f18755845e2c68f872918261f4526d3cafb.tar.gz celevator-2a2d7f18755845e2c68f872918261f4526d3cafb.tar.bz2 celevator-2a2d7f18755845e2c68f872918261f4526d3cafb.tar.xz celevator-2a2d7f18755845e2c68f872918261f4526d3cafb.zip |
Improve robustness against players doing weird unsupported things
Diffstat (limited to 'drive_entity.lua')
-rw-r--r-- | drive_entity.lua | 16 |
1 files changed, 15 insertions, 1 deletions
diff --git a/drive_entity.lua b/drive_entity.lua index de7c43f..0ddd4c4 100644 --- a/drive_entity.lua +++ b/drive_entity.lua @@ -653,7 +653,21 @@ function celevator.drives.entity.moveto(pos,target,inspection) meta:mark_as_private({"apos","dpos","vel","maxvel","state","startpos","doorstate"}) local carid = celevator.get_meta(pos):get_int("carid") local carinfo = minetest.deserialize(celevator.storage:get_string(string.format("car%d",carid))) - if not (carinfo and carinfo.machinepos) then return end + if not (carinfo and carinfo.machinepos and celevator.get_node(carinfo.machinepos).name == "celevator:machine") then + meta:set_string("fault","nomachine") + return + end + if not carinfo.controllerpos then return end + local controllermeta = celevator.get_meta(carinfo.controllerpos) + if controllermeta:get_int("carid") ~= carid then + meta:set_string("fault","controllermismatch") + return + end + local machinemeta = celevator.get_meta(carinfo.machinepos) + if machinemeta:get_int("carid") ~= carid then + meta:set_string("fault","machinemismatch") + return + end local origin = minetest.string_to_pos(meta:get_string("origin")) if not origin then minetest.log("error","[celevator] [entity drive] Invalid origin for drive at "..minetest.pos_to_string(pos)) |