mirror of
				https://gitlab.com/gaelysam/mapgen_rivers.git
				synced 2025-10-31 00:05:35 +01:00 
			
		
		
		
	Fix file opening mode on the Lua side, to avoid crashes on Windows
This commit is contained in:
		
							
								
								
									
										2
									
								
								load.lua
									
									
									
									
									
								
							
							
						
						
									
										2
									
								
								load.lua
									
									
									
									
									
								
							| @@ -1,7 +1,7 @@ | |||||||
| local worldpath = minetest.get_worldpath() .. "/river_data/" | local worldpath = minetest.get_worldpath() .. "/river_data/" | ||||||
|  |  | ||||||
| local function load_map(filename, bytes, signed, size) | local function load_map(filename, bytes, signed, size) | ||||||
| 	local file = io.open(worldpath .. filename, 'r') | 	local file = io.open(worldpath .. filename, 'rb') | ||||||
| 	local data = file:read('*all') | 	local data = file:read('*all') | ||||||
| 	if #data < bytes*size then | 	if #data < bytes*size then | ||||||
| 		data = minetest.decompress(data) | 		data = minetest.decompress(data) | ||||||
|   | |||||||
| @@ -11,21 +11,21 @@ local load_map = dofile(modpath .. 'load.lua') | |||||||
|  |  | ||||||
| local function copy_if_needed(filename) | local function copy_if_needed(filename) | ||||||
| 	local wfilename = world_data_path..filename | 	local wfilename = world_data_path..filename | ||||||
| 	local wfile = io.open(wfilename, 'r') | 	local wfile = io.open(wfilename, 'rb') | ||||||
| 	if wfile then | 	if wfile then | ||||||
| 		wfile:close() | 		wfile:close() | ||||||
| 		return | 		return | ||||||
| 	end | 	end | ||||||
| 	local mfilename = mod_data_path..filename | 	local mfilename = mod_data_path..filename | ||||||
| 	local mfile = io.open(mfilename, 'r') | 	local mfile = io.open(mfilename, 'rb') | ||||||
| 	local wfile = io.open(wfilename, 'w') | 	local wfile = io.open(wfilename, 'wb') | ||||||
| 	wfile:write(mfile:read("*all")) | 	wfile:write(mfile:read("*all")) | ||||||
| 	mfile:close() | 	mfile:close() | ||||||
| 	wfile:close() | 	wfile:close() | ||||||
| end | end | ||||||
|  |  | ||||||
| copy_if_needed('size') | copy_if_needed('size') | ||||||
| local sfile = io.open(world_data_path..'size') | local sfile = io.open(world_data_path..'size', 'r') | ||||||
| local X = tonumber(sfile:read('*l')) | local X = tonumber(sfile:read('*l')) | ||||||
| local Z = tonumber(sfile:read('*l')) | local Z = tonumber(sfile:read('*l')) | ||||||
| sfile:close() | sfile:close() | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user