aboutsummaryrefslogtreecommitdiff
path: root/advtrains
diff options
context:
space:
mode:
Diffstat (limited to 'advtrains')
-rw-r--r--advtrains/advtrains/atc.lua4
-rw-r--r--advtrains/advtrains/helpers.lua11
-rw-r--r--advtrains/advtrains/trackplacer.lua13
-rw-r--r--advtrains/advtrains/tracks.lua6
-rw-r--r--advtrains/advtrains_luaautomation/pcnaming.lua3
5 files changed, 26 insertions, 11 deletions
diff --git a/advtrains/advtrains/atc.lua b/advtrains/advtrains/atc.lua
index a15baa8..192ef0f 100644
--- a/advtrains/advtrains/atc.lua
+++ b/advtrains/advtrains/atc.lua
@@ -98,8 +98,8 @@ advtrains.register_tracks("default", {
atc.controllers[pts]=nil
end,
on_receive_fields = function(pos, formname, fields, player)
- if minetest.is_protected(pos, player:get_player_name()) then
- minetest.chat_send_player(player:get_player_name(), attrans("This position is protected!"))
+ if advtrains.is_protected(pos, player:get_player_name()) then
+ minetest.record_protection_violation(pos, name)
return
end
local meta=minetest.get_meta(pos)
diff --git a/advtrains/advtrains/helpers.lua b/advtrains/advtrains/helpers.lua
index 5761d18..a2b9b16 100644
--- a/advtrains/advtrains/helpers.lua
+++ b/advtrains/advtrains/helpers.lua
@@ -242,3 +242,14 @@ function advtrains.deserialize_inventory(sers, inv)
return false
end
+--is_protected wrapper that checks for protection_bypass privilege
+function advtrains.is_protected(pos, name)
+ if not name then
+ error("advtrains.is_protected() called without name parameter!")
+ end
+ if minetest.check_player_privs(name, {protection_bypass=true}) then
+ --player can bypass protection
+ return false
+ end
+ return minetest.is_protected(pos, name)
+end
diff --git a/advtrains/advtrains/trackplacer.lua b/advtrains/advtrains/trackplacer.lua
index df21608..e039800 100644
--- a/advtrains/advtrains/trackplacer.lua
+++ b/advtrains/advtrains/trackplacer.lua
@@ -194,8 +194,9 @@ function tp.register_track_placer(nnprefix, imgprefix, dispname)
if pointed_thing.type=="node" then
local pos=pointed_thing.above
local upos=vector.subtract(pointed_thing.above, {x=0, y=1, z=0})
- if minetest.is_protected(pos,name) and minetest.is_protected(upos,name) then
- return itemstack
+ if advtrains.is_protected(pos,name) then
+ minetest.record_protection_violation(pos, name)
+ return itemstack
end
if minetest.registered_nodes[minetest.get_node(pos).name] and minetest.registered_nodes[minetest.get_node(pos).name].buildable_to
and minetest.registered_nodes[minetest.get_node(upos).name] and minetest.registered_nodes[minetest.get_node(upos).name].walkable then
@@ -225,7 +226,8 @@ minetest.register_craftitem("advtrains:trackworker",{
end
if pointed_thing.type=="node" then
local pos=pointed_thing.under
- if minetest.is_protected(pos, name) then
+ if advtrains.is_protected(pos, name) then
+ minetest.record_protection_violation(pos, name)
return
end
local node=minetest.get_node(pos)
@@ -267,8 +269,9 @@ minetest.register_craftitem("advtrains:trackworker",{
if pointed_thing.type=="node" then
local pos=pointed_thing.under
local node=minetest.get_node(pos)
- if minetest.is_protected(pos, name) then
- return
+ if advtrains.is_protected(pos, name) then
+ minetest.record_protection_violation(pos, name)
+ return
end
--if not advtrains.is_track_and_drives_on(minetest.get_node(pos).name, advtrains.all_tracktypes) then return end
diff --git a/advtrains/advtrains/tracks.lua b/advtrains/advtrains/tracks.lua
index d4d52c9..90d2ad3 100644
--- a/advtrains/advtrains/tracks.lua
+++ b/advtrains/advtrains/tracks.lua
@@ -490,8 +490,8 @@ function sl.create_slopeplacer_on_place(def, preset)
minetest.chat_send_player(player:get_player_name(), attrans("Can't place: space occupied!"))
return istack
end
- if minetest.is_protected(pos, player:get_player_name()) then
- minetest.chat_send_player(player:get_player_name(), attrans("Can't place: protected position!"))
+ if advtrains.is_protected(pos, player:get_player_name()) then
+ minetest.record_protection_violation(pos, player:get_player_name())
return istack
end
--determine player orientation (only horizontal component)
@@ -525,7 +525,7 @@ function sl.create_slopeplacer_on_place(def, preset)
while step<=lookup.max do
local node=minetest.get_node(vector.add(pos, dirvec))
--next node solid?
- if not minetest.registered_nodes[node.name] or not minetest.registered_nodes[node.name].buildable_to or minetest.is_protected(pos, player:get_player_name()) then
+ if not minetest.registered_nodes[node.name] or not minetest.registered_nodes[node.name].buildable_to or advtrains.is_protected(pos, player:get_player_name()) then
--do slopes of this distance exist?
if lookup[step] then
if minetest.setting_getbool("creative_mode") or istack:get_count()>=step then
diff --git a/advtrains/advtrains_luaautomation/pcnaming.lua b/advtrains/advtrains_luaautomation/pcnaming.lua
index 5604749..18f1017 100644
--- a/advtrains/advtrains_luaautomation/pcnaming.lua
+++ b/advtrains/advtrains_luaautomation/pcnaming.lua
@@ -34,7 +34,8 @@ minetest.register_craftitem("advtrains_luaautomation:pcnaming",{
end
if pointed_thing.type=="node" then
local pos=pointed_thing.under
- if minetest.is_protected(pos, name) then
+ if advtrains.is_protected(pos, pname) then
+ minetest.record_protection_violation(pos, name)
return
end
local node=minetest.get_node(pos)