added separate logging for railway networks

master
Gabriel Pérez-Cerezo 2018-02-18 22:52:57 +01:00
parent 06cdb14f3d
commit 81d637dc76
No known key found for this signature in database
GPG Key ID: 90422B01A46D0B3E
4 changed files with 16 additions and 1 deletions

View File

@ -167,6 +167,7 @@ end
--load/save --load/save
advtrains.fpath=minetest.get_worldpath().."/advtrains" advtrains.fpath=minetest.get_worldpath().."/advtrains"
dofile(advtrains.modpath.."/log.lua")
function advtrains.avt_load() function advtrains.avt_load()
local file, err = io.open(advtrains.fpath, "r") local file, err = io.open(advtrains.fpath, "r")

9
advtrains/log.lua Normal file
View File

@ -0,0 +1,9 @@
-- Log accesses to driver stands and changes to switches
advtrains.logfile = advtrains.fpath .. "_log"
function advtrains.log (event, player, pos, data)
local log = io.open(advtrains.logfile, "a+")
log:write(os.date()..": "..event.." by "..player.." at "..minetest.pos_to_string(pos).." -- "..(data or "").."\n")
log:close()
end

View File

@ -310,7 +310,8 @@ function advtrains.register_tracks(tracktype, def, preset)
end end
ndef.on_rightclick = function(pos, node, player) ndef.on_rightclick = function(pos, node, player)
if minetest.check_player_privs(player:get_player_name(), {train_operator=true}) then if minetest.check_player_privs(player:get_player_name(), {train_operator=true}) then
switchfunc(pos, node) switchfunc(pos, node)
advtrains.log("Switch", player:get_player_name(), pos)
end end
end end
if var.switchmc then if var.switchmc then

View File

@ -1087,6 +1087,9 @@ function wagon:check_seat_group_access(pname, sgr)
if self.seat_groups[sgr].driving_ctrl_access and not minetest.check_player_privs(pname, "train_operator") then if self.seat_groups[sgr].driving_ctrl_access and not minetest.check_player_privs(pname, "train_operator") then
return false, "Missing train_operator privilege." return false, "Missing train_operator privilege."
end end
if self.seat_groups[sgr].driving_ctrl_access then
advtrains.log("Drive", pname, self.object:getpos(), self:train().text_outside)
end
if not self.seat_access then if not self.seat_access then
return true return true
end end
@ -1120,6 +1123,7 @@ function wagon:safe_decouple(pname)
minetest.chat_send_player(pname, "Couple is locked (ask owner or admin to unlock it)") minetest.chat_send_player(pname, "Couple is locked (ask owner or admin to unlock it)")
return false return false
end end
advtrains.log("Discouple", pname, self.object:getpos(), self:train().text_outside)
atprint("wagon:discouple() Splitting train", selftrain_id) atprint("wagon:discouple() Splitting train", selftrain_id)
advtrains.split_train_at_wagon(self)--found in trainlogic.lua advtrains.split_train_at_wagon(self)--found in trainlogic.lua
return true return true