aboutsummaryrefslogtreecommitdiff
path: root/advtrains/init.lua
diff options
context:
space:
mode:
Diffstat (limited to 'advtrains/init.lua')
-rw-r--r--advtrains/init.lua34
1 files changed, 26 insertions, 8 deletions
diff --git a/advtrains/init.lua b/advtrains/init.lua
index c3298a2..828502a 100644
--- a/advtrains/init.lua
+++ b/advtrains/init.lua
@@ -1,4 +1,24 @@
+--[[
+Advanced Trains - Minetest Mod
+
+Copyright (C) 2016-2020 Moritz Blei (orwell96) and contributors
+
+ This program is free software: you can redistribute it and/or modify
+ it under the terms of the GNU Affero General Public License as
+ published by the Free Software Foundation, either version 3 of the
+ License, or (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU Affero General Public License for more details.
+
+ You should have received a copy of the GNU Affero General Public License
+ along with this program. If not, see <https://www.gnu.org/licenses/>.
+
+]]
+
local lot = os.clock()
minetest.log("action", "[advtrains] Loading...")
@@ -177,6 +197,7 @@ dofile(advtrains.modpath.."/path.lua")
dofile(advtrains.modpath.."/trainlogic.lua")
dofile(advtrains.modpath.."/trainhud.lua")
dofile(advtrains.modpath.."/trackplacer.lua")
+dofile(advtrains.modpath.."/copytool.lua")
dofile(advtrains.modpath.."/tracks.lua")
dofile(advtrains.modpath.."/occupation.lua")
dofile(advtrains.modpath.."/atc.lua")
@@ -343,15 +364,12 @@ advtrains.save_component = function (tbl, name)
minetest.log("error", " Failed to serialize advtrains save data!")
return
end
- local temppath = advtrains.fpath.."_"..name.."~"
- local file, err = io.open(temppath, "w")
- if err then
- minetest.log("error", " Failed to write advtrains save data to file "..temppath..": "..(err or "Unknown Error"))
- return
+ local path = advtrains.fpath.."_"..name
+ local success = minetest.safe_file_write(path, datastr)
+
+ if not success then
+ minetest.log("error", " Failed to write advtrains save data to file "..path)
end
- file:write(datastr)
- file:close()
- os.rename(temppath, advtrains.fpath.."_"..name)
end