Skip to content

Commit 59f5597

Browse files
remove complicated diffing/patching mechanism (#8)
Co-authored-by: BuckarooBanzay <BuckarooBanzay@users.noreply.github.com>
1 parent 97f7cfb commit 59f5597

9 files changed

+3
-465
lines changed

apply_diff.lua

-53
This file was deleted.

create_diff.lua

-160
This file was deleted.

diff.spec.lua

-55
This file was deleted.

init.lua

+1-8
Original file line numberDiff line numberDiff line change
@@ -34,15 +34,10 @@ dofile(MP.."/deserialize_mapblock.lua")
3434
dofile(MP.."/localize_nodeids.lua")
3535
dofile(MP.."/functions.lua")
3636

37-
-- diff / patch
38-
dofile(MP.."/create_diff.lua")
39-
dofile(MP.."/apply_diff.lua")
40-
loadfile(MP.."/patch.lua")(global_env)
41-
4237
-- save/load
4338
dofile(MP.."/auto_save.lua")
4439
dofile(MP.."/auto_update.lua")
45-
loadfile(MP.."/save.lua")(global_env)
40+
dofile(MP.."/save.lua")
4641
loadfile(MP.."/data.lua")(global_env)
4742
dofile(MP.."/load.lua")
4843
dofile(MP.."/mapgen.lua")
@@ -77,8 +72,6 @@ if minetest.get_modpath("mtt") and mtt.enabled then
7772
dofile(MP.."/init.spec.lua")
7873
dofile(MP.."/functions.spec.lua")
7974
dofile(MP.."/data.spec.lua")
80-
dofile(MP.."/diff.spec.lua")
81-
dofile(MP.."/patch.spec.lua")
8275
dofile(MP.."/api.spec.lua")
8376
dofile(MP.."/serialize_chunk.spec.lua")
8477
end

load.lua

-31
Original file line numberDiff line numberDiff line change
@@ -5,36 +5,5 @@ function mapsync.load(chunk_pos, vmanip)
55
return true, "No backend available"
66
end
77

8-
-- load baseline chunk (might be non-existent)
98
mapsync.deserialize_chunk(chunk_pos, mapsync.get_chunk_zip_path(backend_def.path, chunk_pos), vmanip)
10-
11-
if backend_def.patch_path then
12-
-- load diff
13-
local f = io.open(mapsync.get_chunk_json_path(backend_def.patch_path, chunk_pos), "r")
14-
if not f then
15-
-- no diff
16-
return true
17-
end
18-
19-
local changed_nodes = {}
20-
for line in f:lines() do
21-
local changed_node = minetest.parse_json(line)
22-
if changed_node then
23-
table.insert(changed_nodes, changed_node)
24-
end
25-
end
26-
f:close()
27-
28-
-- apply diff
29-
local success, msg = mapsync.apply_diff(chunk_pos, changed_nodes)
30-
if not success then
31-
return false, msg
32-
end
33-
34-
-- fix lighting
35-
local mb_pos1, mb_pos2 = mapsync.get_mapblock_bounds_from_chunk(chunk_pos)
36-
local pos1 = mapsync.get_node_bounds_from_mapblock(mb_pos1)
37-
local _, pos2 = mapsync.get_node_bounds_from_mapblock(mb_pos2)
38-
minetest.fix_light(pos1, pos2)
39-
end
409
end

0 commit comments

Comments
 (0)