mirror of
https://github.com/Refactorio/RedMew.git
synced 2025-03-03 14:53:01 +02:00
Fix stress corruption caused by water #552
This commit is contained in:
parent
ef89b1fb8c
commit
f3ebccce0b
@ -176,11 +176,8 @@ local Config = {
|
|||||||
-- minimum distance and noise range required for water to spawn
|
-- minimum distance and noise range required for water to spawn
|
||||||
room_noise_minimum_distance = 9,
|
room_noise_minimum_distance = 9,
|
||||||
room_noise_ranges = {
|
room_noise_ranges = {
|
||||||
{name = 'water', min = 0.84, max = 0.96},
|
{name = 'water', min = 0.54, max = 1},
|
||||||
{name = 'water', min = 0.73, max = 0.81},
|
{name = 'dirt', min = 0.37, max = 0.54}
|
||||||
{name = 'water', min = 0.54, max = 0.7},
|
|
||||||
{name = 'dirt', min = 0.46, max = 0.53},
|
|
||||||
{name = 'dirt', min = 0.37, max = 0.45}
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
-- responsible for resource spawning
|
-- responsible for resource spawning
|
||||||
|
@ -8,6 +8,7 @@ local raise_event = script.raise_event
|
|||||||
local queue_task = Task.queue_task
|
local queue_task = Task.queue_task
|
||||||
local pairs = pairs
|
local pairs = pairs
|
||||||
local pcall = pcall
|
local pcall = pcall
|
||||||
|
local string_find = string.find
|
||||||
|
|
||||||
-- this
|
-- this
|
||||||
local Template = {}
|
local Template = {}
|
||||||
@ -41,6 +42,9 @@ local function insert_next_tiles(data)
|
|||||||
local tiles = {}
|
local tiles = {}
|
||||||
local tile_count = 0
|
local tile_count = 0
|
||||||
local tile_iterator = data.tile_iterator
|
local tile_iterator = data.tile_iterator
|
||||||
|
local teleported = {}
|
||||||
|
local teleported_count = 0
|
||||||
|
local teleport_offset = tiles_per_call + 5
|
||||||
|
|
||||||
pcall(function()
|
pcall(function()
|
||||||
--use pcall to assure tile_iterator is always incremented, to avoid endless loops
|
--use pcall to assure tile_iterator is always incremented, to avoid endless loops
|
||||||
@ -48,14 +52,26 @@ local function insert_next_tiles(data)
|
|||||||
local new_tile = data.tiles[i]
|
local new_tile = data.tiles[i]
|
||||||
tile_count = tile_count + 1
|
tile_count = tile_count + 1
|
||||||
tiles[tile_count] = new_tile
|
tiles[tile_count] = new_tile
|
||||||
|
local tile_pos = new_tile.position
|
||||||
|
|
||||||
if new_tile.name ~= 'out-of-map' then
|
if new_tile.name ~= 'out-of-map' then
|
||||||
local current_tile = get_tile(new_tile.position.x, new_tile.position.y)
|
local current_tile = get_tile(tile_pos.x, tile_pos.y)
|
||||||
if current_tile.name == 'out-of-map' then
|
if current_tile.name == 'out-of-map' then
|
||||||
void_removed_count = void_removed_count + 1
|
void_removed_count = void_removed_count + 1
|
||||||
void_removed[void_removed_count] = {surface = surface, position = current_tile.position}
|
void_removed[void_removed_count] = {surface = surface, position = current_tile.position}
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
if string_find(new_tile.name, "water", 1, true) then --maybe check prototype's collision mask instead?
|
||||||
|
local entities = surface.find_entities{{tile_pos.x, tile_pos.y}, {tile_pos.x + 1, tile_pos.y + 1}}
|
||||||
|
for _, entity in pairs(entities) do
|
||||||
|
if entity.teleport({entity.position.x + teleport_offset, entity.position.y}) then
|
||||||
|
teleported_count = teleported_count + 1
|
||||||
|
teleported[teleported_count] = entity
|
||||||
|
else
|
||||||
|
print("WARNING: entity " .. entity.name .. " failed to teleport out of the way at " .. serpent.line(entity.position))
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end)
|
end)
|
||||||
|
|
||||||
@ -63,6 +79,11 @@ local function insert_next_tiles(data)
|
|||||||
|
|
||||||
surface.set_tiles(tiles)
|
surface.set_tiles(tiles)
|
||||||
|
|
||||||
|
for i = 1, teleported_count do
|
||||||
|
local entity = teleported[i]
|
||||||
|
entity.teleport({entity.position.x - teleport_offset, entity.position.y})
|
||||||
|
end
|
||||||
|
|
||||||
for i = 1, void_removed_count do
|
for i = 1, void_removed_count do
|
||||||
raise_event(on_void_removed, void_removed[i])
|
raise_event(on_void_removed, void_removed[i])
|
||||||
end
|
end
|
||||||
|
Loading…
x
Reference in New Issue
Block a user