diff options
author | Anthony Zhang <azhang9@gmail.com> | 2014-10-24 22:03:31 -0400 |
---|---|---|
committer | Anthony Zhang <azhang9@gmail.com> | 2014-10-24 22:03:31 -0400 |
commit | eb88bf6adee9a1a63f129040020d2730d84fb8f1 (patch) | |
tree | 3ea644fce14fe4dcc149c5956bac689717668d96 /worldedit_commands | |
parent | 02c36c16d5a51ab83fb438daf7219768ef882c22 (diff) | |
parent | 796aa3870d5cd45696cb253024aa75e8bbc2b462 (diff) |
Merge pull request #61 from ShadowNinja/cleanup-serialization
Clean up serialization
Diffstat (limited to 'worldedit_commands')
-rw-r--r-- | worldedit_commands/init.lua | 15 |
1 files changed, 11 insertions, 4 deletions
diff --git a/worldedit_commands/init.lua b/worldedit_commands/init.lua index 3a5fa61..6fce8f0 100644 --- a/worldedit_commands/init.lua +++ b/worldedit_commands/init.lua @@ -911,9 +911,12 @@ minetest.register_chatcommand("we-allocate", { local value = file:read("*a")
file:close()
- if worldedit.valueversion(value) == 0 then --unknown version
- worldedit.player_notify(name, "invalid file: file is invalid or created with newer version of WorldEdit")
+ local version = worldedit.read_header(value)
+ if version == 0 then
+ worldedit.player_notify(name, "File is invalid!")
return
+ elseif version > worldedit.LATEST_SERIALIZATION_VERSION then
+ worldedit.player_notify(name, "File was created with newer version of WorldEdit!")
end
local nodepos1, nodepos2, count = worldedit.allocate(pos, value)
@@ -963,8 +966,12 @@ minetest.register_chatcommand("we-load", { local value = file:read("*a")
file:close()
- if worldedit.valueversion(value) == 0 then --unknown version
- worldedit.player_notify(name, "invalid file: file is invalid or created with newer version of WorldEdit")
+ local version = worldedit.read_header(value)
+ if version == 0 then
+ worldedit.player_notify(name, "File is invalid!")
+ return
+ elseif version > worldedit.LATEST_SERIALIZATION_VERSION then
+ worldedit.player_notify(name, "File was created with newer version of WorldEdit!")
return
end
|