mirror of
https://github.com/sys4-fr/server-nalc.git
synced 2024-12-25 02:00:37 +01:00
Added rofl mod and updated SQLite Extract Script
- Added rofl (you don't need to enable it) - SQLextract.py updated
This commit is contained in:
parent
33bbc85934
commit
04cff1295f
89
mods/rofl/init.lua
Executable file
89
mods/rofl/init.lua
Executable file
@ -0,0 +1,89 @@
|
|||||||
|
----------------------------
|
||||||
|
-- Rollbacks Out of FiLes.
|
||||||
|
-- ROFL
|
||||||
|
--
|
||||||
|
|
||||||
|
rofl = {}
|
||||||
|
rofl.func = {}
|
||||||
|
rofl.datas = {}
|
||||||
|
rofl.datas.filepath = minetest.get_worldpath() .. "/rollback/"
|
||||||
|
rofl.queue = {}
|
||||||
|
|
||||||
|
local function none(v)
|
||||||
|
if not v or v == "None" then
|
||||||
|
return nil
|
||||||
|
else
|
||||||
|
return v
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
minetest.register_chatcommand("rofl", {
|
||||||
|
description = "Save MFF",
|
||||||
|
privs = {server = true},
|
||||||
|
func = function(name)
|
||||||
|
-- Alert
|
||||||
|
minetest.chat_send_all("*** Server Freezing")
|
||||||
|
|
||||||
|
-- The main loop
|
||||||
|
local i = 0
|
||||||
|
local vm = minetest.get_voxel_manip()
|
||||||
|
while true do
|
||||||
|
local file = io.open(rofl.datas.filepath .. "/database-output." .. i .. ".txt", "r")
|
||||||
|
if not file then
|
||||||
|
break
|
||||||
|
end
|
||||||
|
-- [
|
||||||
|
-- id=155,actor=Mg,type=1;
|
||||||
|
-- list=None,index=None,add=None,stacknode=None,stackquantity=None,nodemeta=None;
|
||||||
|
-- x=-18,y=29,z=31;
|
||||||
|
-- oldnode=default:stonebrick,oldparam1=0,oldparam2=None,oldmeta=None;
|
||||||
|
-- newnode=air,newparam1=13,newparam2=None,newmeta=None
|
||||||
|
-- ]
|
||||||
|
for fields in file:lines() do
|
||||||
|
local id = tonumber(string.sub(fields, string.find(fields, "id=")+string.len("id="), string.find(fields, ",actor")-1))
|
||||||
|
local actor = string.sub(fields, string.find(fields, "actor=")+string.len("actor="), string.find(fields, ",type")-1)
|
||||||
|
local action_type = tonumber(string.sub(fields, string.find(fields, "type=")+string.len("type="), string.find(fields, ";list")-1))
|
||||||
|
|
||||||
|
local list = none(string.sub(fields, string.find(fields, "list=")+string.len("list="), string.find(fields, ",index")-1))
|
||||||
|
local index = none(tonumber(string.sub(fields, string.find(fields, "index=")+string.len("index="), string.find(fields, ",add")-1)))
|
||||||
|
local add = none(tonumber(string.sub(fields, string.find(fields, "add=")+string.len("add="), string.find(fields, ",stacknode")-1)))
|
||||||
|
local stacknode = none(string.sub(fields, string.find(fields, "stacknode=")+string.len("stacknode="), string.find(fields, ",stackquantity")-1))
|
||||||
|
local stackquantity = none(tonumber(string.sub(fields, string.find(fields, "stackquantity=")+string.len("stackquantity="), string.find(fields, ",nodemeta")-1)))
|
||||||
|
local nodemeta = none(string.sub(fields, string.find(fields, "nodemeta=")+string.len("nodemeta="), string.find(fields, ";x=")-1))
|
||||||
|
|
||||||
|
local x = none(tonumber(string.sub(fields, string.find(fields, ";x=")+string.len(";x="), string.find(fields, ",y=")-1)))
|
||||||
|
local y = none(tonumber(string.sub(fields, string.find(fields, ",y=")+string.len(",y="), string.find(fields, ",z=")-1)))
|
||||||
|
local z = none(tonumber(string.sub(fields, string.find(fields, ",z=")+string.len(",z="), string.find(fields, ";oldnode=")-1)))
|
||||||
|
|
||||||
|
local oldnode = none(string.sub(fields, string.find(fields, "oldnode=")+string.len("oldnode="), string.find(fields, ",oldparam1")-1))
|
||||||
|
local oldparam1 = none(tonumber(string.sub(fields, string.find(fields, "oldparam1=")+string.len("oldparam1="), string.find(fields, ",oldparam2")-1)))
|
||||||
|
local oldparam2 = none(tonumber(string.sub(fields, string.find(fields, "oldparam2=")+string.len("oldparam2="), string.find(fields, ",oldmeta=")-1)))
|
||||||
|
--local oldmeta
|
||||||
|
|
||||||
|
local newnode = none(string.sub(fields, string.find(fields, "newnode=")+string.len("newnode="), string.find(fields, ",newparam1")-1))
|
||||||
|
local newparam1 = none(tonumber(string.sub(fields, string.find(fields, "newparam1=")+string.len("newparam1="), string.find(fields, ",newparam2")-1)))
|
||||||
|
local newparam2 = none(tonumber(string.sub(fields, string.find(fields, "newparam2=")+string.len("newparam2="), string.find(fields, ",newmeta=")-1)))
|
||||||
|
--local newmeta
|
||||||
|
|
||||||
|
if action_type == 1 then -- TYPE_SETNODE
|
||||||
|
local forced = minetest.forceload_block({x = x, y = y, z = z})
|
||||||
|
if forced then
|
||||||
|
minetest.set_node({x = x, y = y, z = z}, {name = newnode, param1 = newparam1, param2 = newparam2})
|
||||||
|
minetest.forceload_free_block({x = x, y = y, z = z})
|
||||||
|
else
|
||||||
|
minetest.log("error", "[ROFL] Couldn't forceplace block " .. minetest.pos_to_string({x = x, y = y, z = z}))
|
||||||
|
end
|
||||||
|
|
||||||
|
elseif action_type == 2 then -- TYPE_MODIFY_INVENTORY_STACK
|
||||||
|
|
||||||
|
|
||||||
|
else -- TYPE_NOTHING
|
||||||
|
print("W.T.F. is type " .. (action_type or "nil"))
|
||||||
|
|
||||||
|
end
|
||||||
|
end
|
||||||
|
i = i + 1
|
||||||
|
end
|
||||||
|
minetest.chat_send_all("*** Server Up")
|
||||||
|
end,
|
||||||
|
})
|
@ -45,13 +45,13 @@ class Convert_id(object):
|
|||||||
if self.__players.has_key(player_id):
|
if self.__players.has_key(player_id):
|
||||||
return self.__players[player_id]
|
return self.__players[player_id]
|
||||||
else:
|
else:
|
||||||
return("")
|
return None
|
||||||
|
|
||||||
def get_node_name(self, node_id):
|
def get_node_name(self, node_id):
|
||||||
if self.__nodes.has_key(node_id):
|
if self.__nodes.has_key(node_id):
|
||||||
return self.__nodes[node_id]
|
return self.__nodes[node_id]
|
||||||
else:
|
else:
|
||||||
return("")
|
return None
|
||||||
|
|
||||||
########################################################################
|
########################################################################
|
||||||
## Utilities
|
## Utilities
|
||||||
@ -64,7 +64,7 @@ def ston(a):
|
|||||||
if a:
|
if a:
|
||||||
return str(a)
|
return str(a)
|
||||||
else:
|
else:
|
||||||
return ""
|
return None
|
||||||
|
|
||||||
def select_all_nodes(startstamp, endstamp):
|
def select_all_nodes(startstamp, endstamp):
|
||||||
try:
|
try:
|
||||||
@ -75,7 +75,7 @@ def select_all_nodes(startstamp, endstamp):
|
|||||||
print(err)
|
print(err)
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
try:
|
try:
|
||||||
cur.execute("SELECT * FROM action WHERE timestamp >=:startstamp AND timestamp < :endstamp", {"startstamp":startstamp, "endstamp":endstamp})
|
cur.execute("SELECT * FROM action WHERE (NOT nodeMeta OR newNode) AND timestamp >=:startstamp AND timestamp < :endstamp", {"startstamp":startstamp, "endstamp":endstamp})
|
||||||
except sqlite3.OperationalError as err:
|
except sqlite3.OperationalError as err:
|
||||||
print(err)
|
print(err)
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
@ -96,7 +96,7 @@ def readU32(strm):
|
|||||||
|
|
||||||
def decode(chaine):
|
def decode(chaine):
|
||||||
if not chaine :
|
if not chaine :
|
||||||
return "[]"
|
return None
|
||||||
else:
|
else:
|
||||||
strm = StringIO(chaine)
|
strm = StringIO(chaine)
|
||||||
table = "["
|
table = "["
|
||||||
@ -114,7 +114,7 @@ def decode(chaine):
|
|||||||
# Heureusement leur mode d'escape est quasi le même en Python que Lua
|
# Heureusement leur mode d'escape est quasi le même en Python que Lua
|
||||||
table += '%s="%s"' % (key, val.encode('string-escape').replace('"', '\\"'))
|
table += '%s="%s"' % (key, val.encode('string-escape').replace('"', '\\"'))
|
||||||
if n != nEntries-1:
|
if n != nEntries-1:
|
||||||
table += ", "
|
table += ","
|
||||||
table += "]"
|
table += "]"
|
||||||
return table
|
return table
|
||||||
|
|
||||||
@ -122,28 +122,28 @@ def decode(chaine):
|
|||||||
|
|
||||||
def to_table(node):
|
def to_table(node):
|
||||||
# Init bracket and basic datas
|
# Init bracket and basic datas
|
||||||
table = '['
|
table = "["
|
||||||
table += 'id=%d' % node[0]
|
table += 'id=%d' % node[0]
|
||||||
table += ',actor="%s"' % Id.get_player_name(node[1])
|
table += ',actor=%s' % Id.get_player_name(node[1])
|
||||||
table += ',type=%d' % node[3]
|
table += ',type=%d' % node[3]
|
||||||
# Inventory Manipulation
|
# Inventory Manipulation
|
||||||
table += ';list="%s"' % ston(node[4])
|
table += ';list=%s' % node[4]
|
||||||
table += ',index="%s"' % ston(node[5])
|
table += ',index=%s' % node[5]
|
||||||
table += ',add="%s"' % ston(node[6])
|
table += ',add=%s' % node[6]
|
||||||
table += ',stacknode="%s"' % Id.get_node_name(node[7])
|
table += ',stacknode=%s' % Id.get_node_name(node[7])
|
||||||
table += ',stackquantity="%s"' % ston(node[8])
|
table += ',stackquantity=%s' % node[8]
|
||||||
table += ',nodemeta=%s' % node[9]
|
table += ',nodemeta=%s' % node[9]
|
||||||
# Position
|
# Position
|
||||||
table += ';x=%s, y=%s, z=%s' % (node[10], node[11], node[12])
|
table += ';x=%s,y=%s,z=%s' % (node[10], node[11], node[12])
|
||||||
# Old node
|
# Old node
|
||||||
table += ';oldnode="%s"' % Id.get_node_name(node[13])
|
table += ';oldnode=%s' % Id.get_node_name(node[13])
|
||||||
table += ',oldparam1="%s"' % node[14]
|
table += ',oldparam1=%s' % node[14]
|
||||||
table += ',oldparam2="%s"' % ston(node[15])
|
table += ',oldparam2=%s' % ston(node[15])
|
||||||
table += ',oldmeta=%s' % decode(node[16])
|
table += ',oldmeta=%s' % decode(node[16])
|
||||||
# New node
|
# New node
|
||||||
table += ';newnode="%s"' % Id.get_node_name(node[17])
|
table += ';newnode=%s' % Id.get_node_name(node[17])
|
||||||
table += ',newparam1="%s"' % ston(node[18])
|
table += ',newparam1=%s' % ston(node[18])
|
||||||
table += ',newparam2="%s"' % ston(node[19])
|
table += ',newparam2=%s' % ston(node[19])
|
||||||
table += ',newmeta=%s' % decode(node[20])
|
table += ',newmeta=%s' % decode(node[20])
|
||||||
# Ending
|
# Ending
|
||||||
table += ']\n'
|
table += ']\n'
|
||||||
|
Loading…
Reference in New Issue
Block a user