Drop: support for colddb
This commit is contained in:
		| @@ -9,21 +9,12 @@ factions.parcels = {} | ||||
| factions.players = {} | ||||
| factions.player_ips = {} | ||||
|  | ||||
| if factions_config.database == "colddb" then | ||||
|     -- Create cold databases. | ||||
|     factions.root = colddb.Colddb(minetest.get_worldpath() .. "/factions") | ||||
|     factions.factions = factions.root.sub_database("factions") | ||||
|     factions.parcels = factions.root.sub_database("parcels") | ||||
|     factions.players = factions.root.sub_database("players") | ||||
|     factions.player_ips = factions.root.sub_database("ips") | ||||
| elseif factions_config.database == "mod_storage" then | ||||
|     dofile (minetest.get_modpath("fac_database") .. "/storagedb.lua") | ||||
|     factions.root = storagedb.Storagedb("factions") | ||||
|     factions.factions = factions.root.sub_database("factions") | ||||
|     factions.parcels = factions.root.sub_database("parcels") | ||||
|     factions.players = factions.root.sub_database("players") | ||||
|     factions.player_ips = factions.root.sub_database("ips") | ||||
| end | ||||
| dofile (minetest.get_modpath("fac_database") .. "/storagedb.lua") | ||||
| factions.root = storagedb.Storagedb("factions") | ||||
| factions.factions = factions.root.sub_database("factions") | ||||
| factions.parcels = factions.root.sub_database("parcels") | ||||
| factions.players = factions.root.sub_database("players") | ||||
| factions.player_ips = factions.root.sub_database("ips") | ||||
|  | ||||
| -- Memory only storage. | ||||
| factions.onlineplayers = {} | ||||
|   | ||||
| @@ -1,3 +1,2 @@ | ||||
| name = fac_database | ||||
| depends = fac_config | ||||
| optional_depends = colddb | ||||
|   | ||||
| @@ -16,51 +16,31 @@ function storagedb.Storagedb(dir) | ||||
| 	setmetatable(mem_pool_del, {__mode = "kv"}) | ||||
|  | ||||
| 	local function storekey(key) | ||||
|         local list = minetest.deserialize(storage:get_string(directory)) | ||||
|         local list = deserializer(storage:get_string(directory)) | ||||
|         if not list then | ||||
|             list = {} | ||||
|             list[key] = key | ||||
|         else | ||||
|             list[key] = key | ||||
|         end | ||||
|         storage:set_string(directory, minetest.serialize(list)) | ||||
|         storage:set_string(directory, serializer(list)) | ||||
|     end | ||||
|     local function removekey(key) | ||||
|         local list = minetest.deserialize(storage:get_string(directory)) | ||||
|         local list = deserializer(storage:get_string(directory)) | ||||
|         if not list then | ||||
|             list = {} | ||||
|         else | ||||
|             list[key] = nil | ||||
|         end | ||||
|         storage:set_string(directory, minetest.serialize(list)) | ||||
|         storage:set_string(directory, serializer(list)) | ||||
|     end | ||||
|     local function getkeys() | ||||
|         local list = minetest.deserialize(storage:get_string(directory)) | ||||
|         local list = deserializer(storage:get_string(directory)) | ||||
|         if not list then | ||||
|             list = {} | ||||
|         end | ||||
|         return list | ||||
|     end | ||||
| 	 | ||||
| 	self.get_memory_pool = function() | ||||
| 		return mem_pool | ||||
| 	end | ||||
| 	self.set_memory_pool = function(pool) | ||||
| 		mem_pool = pool | ||||
| 	end | ||||
| 	self.add_to_memory_pool = function(value) | ||||
| 		if value then | ||||
| 			add_to_mem_pool = value | ||||
| 		end | ||||
| 		return add_to_mem_pool | ||||
| 	end | ||||
| 	self.get_serializer = function() | ||||
| 		return serializer, deserializer | ||||
| 	end | ||||
| 	self.set_serializer = function(coder, decoder) | ||||
| 		serializer = coder | ||||
| 		deserializer = decoder | ||||
| 	end | ||||
| 	local function load_into_mem(name, _table) | ||||
| 		if add_to_mem_pool then | ||||
| 			mem_pool[name] = {mem = _table} | ||||
| @@ -79,7 +59,7 @@ function storagedb.Storagedb(dir) | ||||
| 			return false | ||||
| 		end | ||||
| 		storekey(name) | ||||
| 		storage:set_string(string.format("%s/%s", directory, name), minetest.serialize(_table)) | ||||
| 		storage:set_string(string.format("%s/%s", directory, name), serializer(_table)) | ||||
| 	end | ||||
| 	local function save_key(name) | ||||
| 		storage:set_string(string.format("%s/%s", directory, name), "") | ||||
| @@ -91,6 +71,25 @@ function storagedb.Storagedb(dir) | ||||
| 		end | ||||
| 		return false | ||||
| 	end | ||||
| 	self.get_memory_pool = function() | ||||
| 		return mem_pool | ||||
| 	end | ||||
| 	self.set_memory_pool = function(pool) | ||||
| 		mem_pool = pool | ||||
| 	end | ||||
| 	self.add_to_memory_pool = function(value) | ||||
| 		if value then | ||||
| 			add_to_mem_pool = value | ||||
| 		end | ||||
| 		return add_to_mem_pool | ||||
| 	end | ||||
| 	self.get_serializer = function() | ||||
| 		return serializer, deserializer | ||||
| 	end | ||||
| 	self.set_serializer = function(coder, decoder) | ||||
| 		serializer = coder | ||||
| 		deserializer = decoder | ||||
| 	end | ||||
| 	self.set_mem = function(name, _table) | ||||
| 		load_into_mem(name, _table) | ||||
| 		mem_pool_del[name] = nil | ||||
|   | ||||
		Reference in New Issue
	
	Block a user