From 4739a3fdacd0f2ceb5281eeef1d0e79f74334438 Mon Sep 17 00:00:00 2001 From: BuckarooBanzay Date: Tue, 30 May 2023 10:16:27 +0200 Subject: [PATCH] pass path --- backend_patch.lua | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/backend_patch.lua b/backend_patch.lua index 166c6df..25b65c9 100644 --- a/backend_patch.lua +++ b/backend_patch.lua @@ -1,11 +1,11 @@ local global_env = ... -local function get_json_path(backend_def, chunk_pos) - return backend_def.path .. "/chunk_" .. minetest.pos_to_string(chunk_pos) .. ".json" +local function get_json_path(prefix, chunk_pos) + return prefix .. "/chunk_" .. minetest.pos_to_string(chunk_pos) .. ".json" end -local function get_path(backend_def, chunk_pos) - return backend_def.path .. "/chunk_" .. minetest.pos_to_string(chunk_pos) .. ".json" +local function get_path(prefix, chunk_pos) + return prefix .. "/chunk_" .. minetest.pos_to_string(chunk_pos) .. ".json" end mapsync.register_backend_handler("patch", { @@ -17,8 +17,8 @@ mapsync.register_backend_handler("patch", { assert(shadow_def.type == "fs") end, save_chunk = function(backend_def, chunk_pos) - local baseline_chunk = mapsync.parse_chunk(get_path(backend_def, chunk_pos)) - local filename = get_json_path(backend_def, chunk_pos) + local baseline_chunk = mapsync.parse_chunk(get_path(backend_def.path, chunk_pos)) + local filename = get_json_path(backend_def.path, chunk_pos) local f = global_env.io.open(filename, "w") mapsync.create_diff(baseline_chunk, chunk_pos, function(changed_node) @@ -30,9 +30,9 @@ mapsync.register_backend_handler("patch", { end, load_chunk = function(backend_def, chunk_pos, vmanip) -- TODO: apply diff if available - return mapsync.deserialize_chunk(chunk_pos, get_path(backend_def, chunk_pos), vmanip) + return mapsync.deserialize_chunk(chunk_pos, get_path(backend_def.path, chunk_pos), vmanip) end, get_manifest = function(backend_def, chunk_pos) - mapsync.get_manifest(get_path(backend_def, chunk_pos)) + mapsync.get_manifest(get_path(backend_def.path, chunk_pos)) end })