Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Random light errors on the surface #22

Closed
TurkeyMcMac opened this issue Jan 28, 2022 · 1 comment
Closed

Random light errors on the surface #22

TurkeyMcMac opened this issue Jan 28, 2022 · 1 comment

Comments

@TurkeyMcMac
Copy link

Sometimes I see light errors like this:
screenshot_20220127_204010

When I regenerate the world, the errors do not appear where they previously did (they appear elsewhere.)

I don't know what causes them, but this patch seems prevent them from cropping up:

--- surface_tunnels-old.lua
+++ surface_tunnels-new.lua
@@ -15,6 +15,7 @@
 	local t_start = os.clock()
 
 	local vm, data, data_param2, area = mapgen_helper.mapgen_vm_data_param2()
+	local data_changed = false
 
 	local eminp = {x=minp.x, y=area.MinEdge.y, z=minp.z}
 	local emaxp = {x=maxp.x, y=area.MaxEdge.y, z=maxp.z}
@@ -51,9 +52,11 @@
 				local index2d = mapgen_helper.index2d(minp, maxp, x, z)
 				local humidity = humiditymap[index2d]
 				if previous_potential_floor_y <= maxp_y and previous_potential_floor_y >= minp_y then
+					data_changed = true
 					df_caverns.tunnel_floor(minp, maxp, area, previous_potential_floor_vi, nvals_cracks, data, data_param2, humidity > 30)
 				end
 				if y <= maxp_y and y >= minp_y then
+					data_changed = true
 					df_caverns.tunnel_ceiling(minp, maxp, area, vi, nvals_cracks, data, data_param2, humidity > 30)
 				end
 				previous_potential_floor_vi = nil
@@ -66,16 +69,18 @@
 		
 	end
 	
-	--send data back to voxelmanip
-	vm:set_data(data)
-	vm:set_param2_data(data_param2)
-	--calc lighting
-	vm:set_lighting({day = 0, night = 0})
-	vm:calc_lighting()
-	
-	vm:update_liquids()
-	--write it to world
-	vm:write_to_map()
+	if data_changed then
+		--send data back to voxelmanip
+		vm:set_data(data)
+		vm:set_param2_data(data_param2)
+		--calc lighting
+		vm:set_lighting({day = 0, night = 0})
+		vm:calc_lighting()
+		
+		vm:update_liquids()
+		--write it to world
+		vm:write_to_map()
+	end
 	
 	local time_taken = os.clock() - t_start -- how long this chunk took, in seconds
 	mapgen_helper.record_time("df_caverns surface tunnels", time_taken)

My Minetest version is 5.5.0-dev with LuaJIT. My operating system is Ubuntu 21.10. My computer's architecture is x86_64.

FaceDeer added a commit that referenced this issue Jul 15, 2022
@FaceDeer
Copy link
Owner

Sorry it took so long for me to be dragged back to the modding biz. I've added your changes, even without the lighting improvement it seems like this will be a nice efficiency improvement.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants