From 8261c92e01592e772f6865bea3c66764e8b2e02d Mon Sep 17 00:00:00 2001 From: LeMagnesium Date: Thu, 9 Jul 2015 15:32:54 +0200 Subject: [PATCH] Added SQLiteExact script --- minetestforfun_game/mods/stairs/init.lua | 4 +- .../mods/stairs/models/stairs.obj | 0 mods/arrow_signs/models/arrow_sign.obj | 0 mods/warps/LICENSE | 0 mods/warps/README | 0 mods/warps/depends.txt | 0 mods/warps/description.txt | 0 mods/warps/init.lua | 0 mods/warps/models/warps_warpstone.obj | 0 mods/warps/sounds/LICENSE | 0 mods/warps/sounds/warps_plop.ogg | Bin mods/warps/sounds/warps_woosh.ogg | Bin mods/warps/textures/warps_warpstone.png | Bin mods/warps/textures/warps_warpstone_guide.png | Bin mods/watershed/README.txt | 0 mods/watershed/depends.txt | 0 mods/watershed/functions.lua | 0 mods/watershed/init.lua | 26 +-- mods/watershed/license.txt | 0 mods/watershed/nodes.lua | 0 .../textures/watershed_acacialeaf.png | Bin .../textures/watershed_acacialing.png | Bin .../textures/watershed_acaciatree.png | Bin .../textures/watershed_acaciatreetop.png | Bin .../textures/watershed_acaciawood.png | Bin .../textures/watershed_bucketfreshwater.png | Bin mods/watershed/textures/watershed_cloud.png | Bin .../watershed/textures/watershed_drygrass.png | Bin .../watershed/textures/watershed_freshice.png | Bin .../textures/watershed_freshwater.png | Bin .../textures/watershed_freshwateranim.png | Bin .../textures/watershed_freshwaterflowanim.png | Bin .../textures/watershed_goldengrass.png | Bin mods/watershed/textures/watershed_icydirt.png | Bin mods/watershed/textures/watershed_light.png | Bin .../textures/watershed_luxcrystal.png | Bin mods/watershed/textures/watershed_luxore.png | Bin .../watershed/textures/watershed_mixwater.png | Bin .../textures/watershed_mixwateranim.png | Bin .../textures/watershed_mixwaterflowanim.png | Bin mods/watershed/textures/watershed_needles.png | Bin .../textures/watershed_permafrost.png | Bin .../watershed/textures/watershed_pineling.png | Bin .../watershed/textures/watershed_pinetree.png | Bin .../textures/watershed_pinetreetop.png | Bin .../watershed/textures/watershed_pinewood.png | Bin .../textures/watershed_redcobble.png | Bin other_things/scripts/SQLextract.py | 149 ++++++++++++++++++ 48 files changed, 164 insertions(+), 15 deletions(-) mode change 100644 => 100755 minetestforfun_game/mods/stairs/models/stairs.obj mode change 100644 => 100755 mods/arrow_signs/models/arrow_sign.obj mode change 100644 => 100755 mods/warps/LICENSE mode change 100644 => 100755 mods/warps/README mode change 100644 => 100755 mods/warps/depends.txt mode change 100644 => 100755 mods/warps/description.txt mode change 100644 => 100755 mods/warps/init.lua mode change 100644 => 100755 mods/warps/models/warps_warpstone.obj mode change 100644 => 100755 mods/warps/sounds/LICENSE mode change 100644 => 100755 mods/warps/sounds/warps_plop.ogg mode change 100644 => 100755 mods/warps/sounds/warps_woosh.ogg mode change 100644 => 100755 mods/warps/textures/warps_warpstone.png mode change 100644 => 100755 mods/warps/textures/warps_warpstone_guide.png mode change 100644 => 100755 mods/watershed/README.txt mode change 100644 => 100755 mods/watershed/depends.txt mode change 100644 => 100755 mods/watershed/functions.lua mode change 100644 => 100755 mods/watershed/init.lua mode change 100644 => 100755 mods/watershed/license.txt mode change 100644 => 100755 mods/watershed/nodes.lua mode change 100644 => 100755 mods/watershed/textures/watershed_acacialeaf.png mode change 100644 => 100755 mods/watershed/textures/watershed_acacialing.png mode change 100644 => 100755 mods/watershed/textures/watershed_acaciatree.png mode change 100644 => 100755 mods/watershed/textures/watershed_acaciatreetop.png mode change 100644 => 100755 mods/watershed/textures/watershed_acaciawood.png mode change 100644 => 100755 mods/watershed/textures/watershed_bucketfreshwater.png mode change 100644 => 100755 mods/watershed/textures/watershed_cloud.png mode change 100644 => 100755 mods/watershed/textures/watershed_drygrass.png mode change 100644 => 100755 mods/watershed/textures/watershed_freshice.png mode change 100644 => 100755 mods/watershed/textures/watershed_freshwater.png mode change 100644 => 100755 mods/watershed/textures/watershed_freshwateranim.png mode change 100644 => 100755 mods/watershed/textures/watershed_freshwaterflowanim.png mode change 100644 => 100755 mods/watershed/textures/watershed_goldengrass.png mode change 100644 => 100755 mods/watershed/textures/watershed_icydirt.png mode change 100644 => 100755 mods/watershed/textures/watershed_light.png mode change 100644 => 100755 mods/watershed/textures/watershed_luxcrystal.png mode change 100644 => 100755 mods/watershed/textures/watershed_luxore.png mode change 100644 => 100755 mods/watershed/textures/watershed_mixwater.png mode change 100644 => 100755 mods/watershed/textures/watershed_mixwateranim.png mode change 100644 => 100755 mods/watershed/textures/watershed_mixwaterflowanim.png mode change 100644 => 100755 mods/watershed/textures/watershed_needles.png mode change 100644 => 100755 mods/watershed/textures/watershed_permafrost.png mode change 100644 => 100755 mods/watershed/textures/watershed_pineling.png mode change 100644 => 100755 mods/watershed/textures/watershed_pinetree.png mode change 100644 => 100755 mods/watershed/textures/watershed_pinetreetop.png mode change 100644 => 100755 mods/watershed/textures/watershed_pinewood.png mode change 100644 => 100755 mods/watershed/textures/watershed_redcobble.png create mode 100755 other_things/scripts/SQLextract.py diff --git a/minetestforfun_game/mods/stairs/init.lua b/minetestforfun_game/mods/stairs/init.lua index ca2aff1f..4c66893c 100755 --- a/minetestforfun_game/mods/stairs/init.lua +++ b/minetestforfun_game/mods/stairs/init.lua @@ -146,7 +146,7 @@ function stairs.register_slab(subname, recipeitem, groups, images, description, end return itemstack end - + -- Upside down slabs if p0.y-1 == p1.y then -- Turn into full block if pointing at a existing slab @@ -275,7 +275,7 @@ stairs.register_stair_and_slab("sandstone", "default:sandstone", "Sandstone Stair", "Sandstone Slab", default.node_sound_stone_defaults()) - + stairs.register_stair_and_slab("sandstonebrick", "default:sandstonebrick", {crumbly=2,cracky=2}, {"default_sandstone_brick.png"}, diff --git a/minetestforfun_game/mods/stairs/models/stairs.obj b/minetestforfun_game/mods/stairs/models/stairs.obj old mode 100644 new mode 100755 diff --git a/mods/arrow_signs/models/arrow_sign.obj b/mods/arrow_signs/models/arrow_sign.obj old mode 100644 new mode 100755 diff --git a/mods/warps/LICENSE b/mods/warps/LICENSE old mode 100644 new mode 100755 diff --git a/mods/warps/README b/mods/warps/README old mode 100644 new mode 100755 diff --git a/mods/warps/depends.txt b/mods/warps/depends.txt old mode 100644 new mode 100755 diff --git a/mods/warps/description.txt b/mods/warps/description.txt old mode 100644 new mode 100755 diff --git a/mods/warps/init.lua b/mods/warps/init.lua old mode 100644 new mode 100755 diff --git a/mods/warps/models/warps_warpstone.obj b/mods/warps/models/warps_warpstone.obj old mode 100644 new mode 100755 diff --git a/mods/warps/sounds/LICENSE b/mods/warps/sounds/LICENSE old mode 100644 new mode 100755 diff --git a/mods/warps/sounds/warps_plop.ogg b/mods/warps/sounds/warps_plop.ogg old mode 100644 new mode 100755 diff --git a/mods/warps/sounds/warps_woosh.ogg b/mods/warps/sounds/warps_woosh.ogg old mode 100644 new mode 100755 diff --git a/mods/warps/textures/warps_warpstone.png b/mods/warps/textures/warps_warpstone.png old mode 100644 new mode 100755 diff --git a/mods/warps/textures/warps_warpstone_guide.png b/mods/warps/textures/warps_warpstone_guide.png old mode 100644 new mode 100755 diff --git a/mods/watershed/README.txt b/mods/watershed/README.txt old mode 100644 new mode 100755 diff --git a/mods/watershed/depends.txt b/mods/watershed/depends.txt old mode 100644 new mode 100755 diff --git a/mods/watershed/functions.lua b/mods/watershed/functions.lua old mode 100644 new mode 100755 diff --git a/mods/watershed/init.lua b/mods/watershed/init.lua old mode 100644 new mode 100755 index 58e20580..9012918a --- a/mods/watershed/init.lua +++ b/mods/watershed/init.lua @@ -229,7 +229,7 @@ local nobj_cave1 = nil local nobj_cave2 = nil local nobj_cave3 = nil local nobj_cave4 = nil - + local nobj_mid = nil local nobj_base = nil local nobj_xlscale = nil @@ -271,7 +271,7 @@ function watershed_chunkgen(x0, y0, z0, x1, y1, z1, area, data) local c_clay = minetest.get_content_id("default:clay") local c_grass5 = minetest.get_content_id("default:grass_5") local c_obsidian = minetest.get_content_id("default:obsidian") - + local c_wsfreshwater = minetest.get_content_id("watershed:freshwater") local c_wsmixwater = minetest.get_content_id("watershed:mixwater") local c_wsstone = minetest.get_content_id("watershed:stone") @@ -301,7 +301,7 @@ function watershed_chunkgen(x0, y0, z0, x1, y1, z1, area, data) nobj_cave2 = nobj_cave2 or minetest.get_perlin_map(np.cave2, chulensxyz) nobj_cave3 = nobj_cave3 or minetest.get_perlin_map(np.cave3, chulensxyz) nobj_cave4 = nobj_cave4 or minetest.get_perlin_map(np.cave4, chulensxyz) - + nobj_mid = nobj_mid or minetest.get_perlin_map(np.mid, chulensxz) nobj_base = nobj_base or minetest.get_perlin_map(np.base, chulensxz) nobj_xlscale = nobj_xlscale or minetest.get_perlin_map(np.xlscale, chulensxz) @@ -317,7 +317,7 @@ function watershed_chunkgen(x0, y0, z0, x1, y1, z1, area, data) local nvals_cave2 = nobj_cave2:get3dMap_flat(minposxyz) local nvals_cave3 = nobj_cave3:get3dMap_flat(minposxyz) local nvals_cave4 = nobj_cave4:get3dMap_flat(minposxyz) - + local nvals_mid = nobj_mid:get2dMap_flat(minposxz) local nvals_base = nobj_base:get2dMap_flat(minposxz) local nvals_xlscale = nobj_xlscale:get2dMap_flat(minposxz) @@ -348,7 +348,7 @@ function watershed_chunkgen(x0, y0, z0, x1, y1, z1, area, data) local n_cave2 = nvals_cave2[nixyz] local n_cave3 = nvals_cave3[nixyz] local n_cave4 = nvals_cave4[nixyz] - + local n_absmid = math.abs(nvals_mid[nixz]) local n_absbase = math.abs(nvals_base[nixz]) local n_xlscale = nvals_xlscale[nixz] @@ -373,13 +373,13 @@ function watershed_chunkgen(x0, y0, z0, x1, y1, z1, area, data) local tlava = TLAVA * (1 - n_magma ^ 4 * terblen ^ 16 * 0.6) -- lava threshold local ysand = YSAV + n_fissure * SAMP + math.random() * 2 -- sandline local bergdep = math.abs(n_seam) * BERGDEP -- iceberg depth - + local nofis = false -- set fissure bool - if math.abs(n_fissure) >= TFIS + if math.abs(n_fissure) >= TFIS and n_cave1 ^ 2 + n_cave2 ^ 2 + n_cave3 ^ 2 + n_cave4 ^ 2 >= 0.07 then -- from Valleys Mapgen nofis = true end - + local biome = false -- select biome for node if n_temp < LOTET + (math.random() - 0.5) * BLEND then if n_humid < LOHUT + (math.random() - 0.5) * BLEND then @@ -406,7 +406,7 @@ function watershed_chunkgen(x0, y0, z0, x1, y1, z1, area, data) biome = 5 -- grassland end end - + -- overgeneration and in-chunk generation if y == y0 - 1 then -- node layer below chunk, initialise tables under[si] = 0 @@ -626,7 +626,7 @@ function watershed_chunkgen(x0, y0, z0, x1, y1, z1, area, data) end end elseif under[si] == 10 then -- dunes - if math.random(flora.DUGCHA) == 2 and y > YSAV + if math.random(flora.DUGCHA) == 2 and y > YSAV and biome >= 4 then data[vi] = c_wsgoldengrass end @@ -727,7 +727,7 @@ minetest.register_chatcommand("regen",{ local area = VoxelArea:new({MinEdge=emin, MaxEdge=emax}) local data = vm:get_data() - watershed_chunkgen(x0, y0, z0, x1, y1, z1, area, data) + watershed_chunkgen(x0, y0, z0, x1, y1, z1, area, data) vm:set_data(data) minetest.generate_ores(vm, minp, maxp) @@ -758,7 +758,7 @@ minetest.register_on_generated(function(minp, maxp, seed) local x0 = minp.x local y0 = minp.y local z0 = minp.z - + print ("[watershed] generate mapchunk minp ("..x0.." "..y0.." "..z0..")") local vm, emin, emax = minetest.get_mapgen_object("voxelmanip") @@ -774,7 +774,7 @@ minetest.register_on_generated(function(minp, maxp, seed) vm:calc_lighting() vm:write_to_map(data) vm:update_liquids() - + local chugent = math.ceil((os.clock() - t1) * 1000) print ("[watershed] "..chugent.." ms") end) diff --git a/mods/watershed/license.txt b/mods/watershed/license.txt old mode 100644 new mode 100755 diff --git a/mods/watershed/nodes.lua b/mods/watershed/nodes.lua old mode 100644 new mode 100755 diff --git a/mods/watershed/textures/watershed_acacialeaf.png b/mods/watershed/textures/watershed_acacialeaf.png old mode 100644 new mode 100755 diff --git a/mods/watershed/textures/watershed_acacialing.png b/mods/watershed/textures/watershed_acacialing.png old mode 100644 new mode 100755 diff --git a/mods/watershed/textures/watershed_acaciatree.png b/mods/watershed/textures/watershed_acaciatree.png old mode 100644 new mode 100755 diff --git a/mods/watershed/textures/watershed_acaciatreetop.png b/mods/watershed/textures/watershed_acaciatreetop.png old mode 100644 new mode 100755 diff --git a/mods/watershed/textures/watershed_acaciawood.png b/mods/watershed/textures/watershed_acaciawood.png old mode 100644 new mode 100755 diff --git a/mods/watershed/textures/watershed_bucketfreshwater.png b/mods/watershed/textures/watershed_bucketfreshwater.png old mode 100644 new mode 100755 diff --git a/mods/watershed/textures/watershed_cloud.png b/mods/watershed/textures/watershed_cloud.png old mode 100644 new mode 100755 diff --git a/mods/watershed/textures/watershed_drygrass.png b/mods/watershed/textures/watershed_drygrass.png old mode 100644 new mode 100755 diff --git a/mods/watershed/textures/watershed_freshice.png b/mods/watershed/textures/watershed_freshice.png old mode 100644 new mode 100755 diff --git a/mods/watershed/textures/watershed_freshwater.png b/mods/watershed/textures/watershed_freshwater.png old mode 100644 new mode 100755 diff --git a/mods/watershed/textures/watershed_freshwateranim.png b/mods/watershed/textures/watershed_freshwateranim.png old mode 100644 new mode 100755 diff --git a/mods/watershed/textures/watershed_freshwaterflowanim.png b/mods/watershed/textures/watershed_freshwaterflowanim.png old mode 100644 new mode 100755 diff --git a/mods/watershed/textures/watershed_goldengrass.png b/mods/watershed/textures/watershed_goldengrass.png old mode 100644 new mode 100755 diff --git a/mods/watershed/textures/watershed_icydirt.png b/mods/watershed/textures/watershed_icydirt.png old mode 100644 new mode 100755 diff --git a/mods/watershed/textures/watershed_light.png b/mods/watershed/textures/watershed_light.png old mode 100644 new mode 100755 diff --git a/mods/watershed/textures/watershed_luxcrystal.png b/mods/watershed/textures/watershed_luxcrystal.png old mode 100644 new mode 100755 diff --git a/mods/watershed/textures/watershed_luxore.png b/mods/watershed/textures/watershed_luxore.png old mode 100644 new mode 100755 diff --git a/mods/watershed/textures/watershed_mixwater.png b/mods/watershed/textures/watershed_mixwater.png old mode 100644 new mode 100755 diff --git a/mods/watershed/textures/watershed_mixwateranim.png b/mods/watershed/textures/watershed_mixwateranim.png old mode 100644 new mode 100755 diff --git a/mods/watershed/textures/watershed_mixwaterflowanim.png b/mods/watershed/textures/watershed_mixwaterflowanim.png old mode 100644 new mode 100755 diff --git a/mods/watershed/textures/watershed_needles.png b/mods/watershed/textures/watershed_needles.png old mode 100644 new mode 100755 diff --git a/mods/watershed/textures/watershed_permafrost.png b/mods/watershed/textures/watershed_permafrost.png old mode 100644 new mode 100755 diff --git a/mods/watershed/textures/watershed_pineling.png b/mods/watershed/textures/watershed_pineling.png old mode 100644 new mode 100755 diff --git a/mods/watershed/textures/watershed_pinetree.png b/mods/watershed/textures/watershed_pinetree.png old mode 100644 new mode 100755 diff --git a/mods/watershed/textures/watershed_pinetreetop.png b/mods/watershed/textures/watershed_pinetreetop.png old mode 100644 new mode 100755 diff --git a/mods/watershed/textures/watershed_pinewood.png b/mods/watershed/textures/watershed_pinewood.png old mode 100644 new mode 100755 diff --git a/mods/watershed/textures/watershed_redcobble.png b/mods/watershed/textures/watershed_redcobble.png old mode 100644 new mode 100755 diff --git a/other_things/scripts/SQLextract.py b/other_things/scripts/SQLextract.py new file mode 100755 index 00000000..e328d249 --- /dev/null +++ b/other_things/scripts/SQLextract.py @@ -0,0 +1,149 @@ +#!/usr/bin/env python +# -*- coding: UTF-8 -*- + +import sys, os, sqlite3 + +home = os.environ.get("HOME") +db = "%s/rollback/rollback.sqlite" % (home) + + +def select_all_nodes(stamp): + try: + conn = sqlite3.connect(db) + conn.text_factory = str + cur = conn.cursor() + except sqlite3.OperationalError as err: + print(err) + sys.exit(1) + try: + cur.execute("SELECT * FROM action WHERE timestamp >=:stamp", {"stamp":stamp}) + except sqlite3.OperationalError as err: + print(err) + sys.exit(1) + else: + result = cur.fetchall() + finally: + cur.close() + conn.close() + return(result) + + + + +def select_nodes_id(): + try: + conn = sqlite3.connect(db) + cur = conn.cursor() + except sqlite3.OperationalError as err: + print(err) + sys.exit(1) + try: + cur.execute("SELECT * FROM node") + except sqlite3.OperationalError as err: + print(err) + sys.exit(1) + else: + result = cur.fetchall() + finally: + cur.close() + conn.close() + return(result) + + +def get_node(nodeid): + if not nodeid: + return None + try: + return select_nodes_id()[nodeid-1][1] + except IndexError: + print(nodeid) + + +def select_player_id(table, player_name): + try: + conn = sqlite3.connect(db) + cur = conn.cursor() + except: + print("Problème avec la base de données") + return("") + try: + cur.execute("SELECT id FROM " + str(table) + " WHERE name=:name", {"name": "player:%s" % player_name}) + except sqlite3.OperationalError as err: + print(err) + return ("") + else: + result = cur.fetchall() + finally: + cur.close() + conn.close() + return(result) + +def get_player(id): + try: + conn = sqlite3.connect(db) + cur = conn.cursor() + except: + print("problème avec la base de données") + return ("") + try: + cur.execute("SELECT name from actor WHERE id=%d" % id) + except sqlite3.OperationalError as err: + print(err) + return ("") + else: + result = cur.fetchall()[0][0] + finally: + cur.close() + conn.close() + return result[len("player:"):] + + +def ston(a): + if a: + return str(a) + else: + return a + +def write_list(nodes): + try: + name = "database-output.txt" + f = open(name, "w") + except Exception as err: + print(err) + sys.exit(1) + + for node in nodes: + f.write("[") + f.write("id=%d" % node[0]) + f.write(";actor=%s" % get_player(node[1])) + f.write(";type=%d" % node[3]) + f.write(";list=%s" % ston(node[4])) + f.write(",index=%s" % ston(node[5])) + f.write(",add=%s" % ston(node[6])) + f.write(",stacknode=%s" % get_node(node[7])) + f.write(",stackquantity=%s" % ston(node[8])) + f.write(",nodemeta=%s" % ston(node[9])) + f.write(";x=%s,y=%s,z=%s" % (node[10], node[11], node[12])) + f.write(";oldnode=%s" % get_node(node[13])) + f.write(",oldparam1=%s" % node[14]) + f.write(",oldparam2=%s" % ston(node[15])) + f.write(",oldmeta=%s" % ston(node[16])) + f.write(":newnode=%s" % get_node(node[17])) + f.write(",newparam1=%s" % ston(node[18])) + f.write(",newparam2=%s" % ston(node[19])) + f.write(",newmeta=%s" % ston(node[20])) + f.write("]\n") + + f.close() + + + + +if __name__ == '__main__': + #select all nodes player as set i where time >= time + all_nodes = select_all_nodes(0) #1418613979) + + # write in file +# for x in range(0,len(all_nodes)): +# print(all_nodes[x]) + write_list(all_nodes)