| Mode | Name | Size | |
| -rw-r--r-- | CMakeLists.txt | 20712 | logplain |
| -rw-r--r-- | activeobject.h | 1584 | logplain |
| -rw-r--r-- | ban.cpp | 3997 | logplain |
| -rw-r--r-- | ban.h | 1505 | logplain |
| -rw-r--r-- | base64.cpp | 3900 | logplain |
| -rw-r--r-- | base64.h | 250 | logplain |
| -rw-r--r-- | biome.cpp | 5633 | logplain |
| -rw-r--r-- | biome.h | 2330 | logplain |
| -rw-r--r-- | camera.cpp | 22124 | logplain |
| -rw-r--r-- | camera.h | 5629 | logplain |
| -rw-r--r-- | cavegen.cpp | 16356 | logplain |
| -rw-r--r-- | cavegen.h | 2786 | logplain |
| d--------- | cguittfont | 248 | logplain |
| -rw-r--r-- | chat.cpp | 17078 | logplain |
| -rw-r--r-- | chat.h | 7207 | logplain |
| -rw-r--r-- | client.cpp | 70957 | logplain |
| -rw-r--r-- | client.h | 12792 | logplain |
| -rw-r--r-- | clientiface.cpp | 19000 | logplain |
| -rw-r--r-- | clientiface.h | 1
2. delete <filename>
3. moves <filename>.new to <filename>
plain |
| -rw-r--r-- | clientmap.cpp | 24843 | logplain |
| -rw-r--r-- | clientmap.h | 3630 | logplain |
| -rw-r--r-- | clientmedia.cpp | 19587 | logplain |
| -rw-r--r-- | clientmedia.h | 4455 | logplain |
| -rw-r--r-- | clientobject.cpp | 1773 | logplain |
| -rw-r--r-- | clientobject.h | 3751 | logplain |
| -rw-r--r-- | clientserver.h | 15155 | logplain |
| -rw-r--r-- | clientsimpleobject.h | 1113 | logplain |
| -rw-r--r-- | clouds.cpp | 9724 | logplain |
| -rw-r--r-- | clouds.h | 1963 | logplain |
| -rw-r--r-- | cmake_config.h.in | 1173 | logplain |
| -rw-r--r-- | cmake_config_githash.h.in | 233 | logplain |
| -rw-r--r-- | collision.cpp | 17463 | logplain |
| -rw-r--r-- | collision.h | 2763 | logplain |
| -rw-r--r-- | config.h | 1809 | logplain |
| -rw-r--r-- | connection.cpp | 81939 | logplai
-- The callback's first return value is returned by load_atomic
function serialize_lib.load_atomic(filename, callback)
local cbfunc = callback or ser.read_from_fd
-- try <filename>
local file, ret = io.open(filename, "rb")
if file then
-- read the file using the callback
local success
success, ret = pcall(cbfunc, file)
if success then
return ret
end
end
if minetest.settings:get_bool("serialize_lib_strict_loading", true) then
serialize_lib.save_lock = true
error("Loading data from file '"..filename.."' failed:\n"
..ret.."\nDisable Strict Loading to ignore.")
end
serialize_lib.log_warn("Loading data from file '"..filename.."' failed, trying .new fallback:")
serialize_lib.log_warn(ret)
-- try <filename>.new
file, ret = io.open(filename..".new", "rb")
if file then
-- read the file using the callback
local success
success, ret = pcall(cbfunc, file)
if success then
return ret
end
end
serialize_lib.log_error("Unable to load data from '"..filename..".new':")
serialize_lib.log_error(ret)
serialize_lib.log_error("Note: This message is normal when the mod is loaded the first time on this world.")
return nil, ret
end
-- Save a file atomically (as described above)
-- 'data' is the data to be saved (when a callback is used, this can be nil)
-- if 'callback' is nil:
-- data must be a table, and is serialized into the file
-- if 'callback' is a function (signature func(data, file_handle) ):
-- Opens the file and calls callback on it. The 'data' argument is the data passed to save_atomic().
-- If the callback function throws an error, and strict loading is enabled, that error is propagated.
-- The callback's first return value is returned by load_atomic
-- Important: the callback must close the file in all cases!
function serialize_lib.save_atomic(data, filename, callback, config)
if serialize_lib.save_lock then
serialize_lib.log_warn("Instructed to save '"..filename.."', but save lock is active!")
return nil
end
local cbfunc = callback or ser.write_to_fd
local file, ret = io.open(filename..".new", "wb")
if file then
-- save the file using the callback
local success
success, ret = pcall(cbfunc, data, file)
if success then
return save_atomic_move_file(filename)
end
end
serialize_lib.log_error("Unable to save data to '"..filename..".new':")
serialize_lib.log_error(ret)
return nil, ret
end
-- Saves multiple files synchronously. First writes all data to all <filename>.new files,
-- then moves all files in quick succession to avoid inconsistent backups.
-- parts_table is a table where the keys are used as part of the filename and the values
-- are the respective data written to it.
-- e.g. if parts_table={foo={...}, bar={...}}, then <filename_prefix>foo and <filename_prefix>bar are written out.
-- if 'callbacks_table' is defined, it is consulted for callbacks the same way save_atomic does.
-- example: if callbacks_table = {foo = func()...}, then the callback is used during writing of file 'foo' (but not for 'bar')
-- Note however that you must at least insert a "true" in the parts_table if you don't use the data argument.
-- Important: the callback must close the file in all cases!
function serialize_lib.save_atomic_multiple(parts_table, filename_prefix, callbacks_table, config)
if serialize_lib.save_lock then
serialize_lib.log_warn("Instructed to save '"..filename_prefix.."' (multiple), but save lock is active!")
return nil
end
for subfile, data in pairs(parts_table) do
local filename = filename_prefix..subfile
local cbfunc = ser.write_to_fd
if callbacks_table and callbacks_table[subfile] then
cbfunc = callbacks_table[subfile]
end
local success = false
local file, ret = io.open(filename..".new", "wb")
if file then
-- save the file using the callback
success, ret = pcall(cbfunc, data, file, config)
end
if not success then
serialize_lib.log_error("Unable to save data to '"..filename..".new':")
serialize_lib.log_error(ret)
return nil, ret
end
end
local first_error
for file, _ in pairs(parts_table) do
local filename = filename_prefix..file
local succ, err = save_atomic_move_file(filename)
if not succ and not first_error then
first_error = err
end
end
return not first_error, first_error -- either true,nil or nil,error
end
|