From acdc7369b3ed4db0b1a64fabd8346fbd147f8a49 Mon Sep 17 00:00:00 2001 From: danielmartin0 Date: Thu, 26 May 2022 12:47:05 +0100 Subject: [PATCH] fix: structure generation issue on swamp --- control.lua | 4 ++-- maps/pirates/commands.lua | 22 ++++++++++++++++++++++ maps/pirates/tick_functions.lua | 5 +++++ 3 files changed, 29 insertions(+), 2 deletions(-) diff --git a/control.lua b/control.lua index 14b826b9..21182d2e 100644 --- a/control.lua +++ b/control.lua @@ -1,6 +1,6 @@ require 'utils.data_stages' _LIFECYCLE = _STAGE.control -- Control stage -_DEBUG = false +_DEBUG = true _DUMP_ENV = false require 'utils.server' @@ -112,7 +112,7 @@ require 'utils.freeplay' --require 'maps.chronosphere.main' --![[Adventure as a crew of pirates]]-- ---require 'maps.pirates.main' +require 'maps.pirates.main' --![[Launch rockets in increasingly harder getting worlds.]]-- --require 'maps.journey.main' diff --git a/maps/pirates/commands.lua b/maps/pirates/commands.lua index 628fd085..829ceffb 100644 --- a/maps/pirates/commands.lua +++ b/maps/pirates/commands.lua @@ -804,6 +804,28 @@ if _DEBUG then end end) + commands.add_command( + '1/4', + 'is a dev command.', + function(cmd) + local param = tostring(cmd.parameter) + if check_admin(cmd) then + local player = game.players[cmd.player_index] + game.speed = 0.5 + end + end) + + commands.add_command( + '1/2', + 'is a dev command.', + function(cmd) + local param = tostring(cmd.parameter) + if check_admin(cmd) then + local player = game.players[cmd.player_index] + game.speed = 0.5 + end + end) + commands.add_command( '1', 'is a dev command.', diff --git a/maps/pirates/tick_functions.lua b/maps/pirates/tick_functions.lua index 77fb1ff1..fd138515 100644 --- a/maps/pirates/tick_functions.lua +++ b/maps/pirates/tick_functions.lua @@ -449,6 +449,11 @@ function Public.place_cached_structures(tickinterval) if (not destination.dynamic_data) or (not destination.dynamic_data.structures_waiting_to_be_placed) or (not surface_name) or (not game.surfaces[surface_name]) or (not game.surfaces[surface_name].valid) then return end + if not (memory.boat and memory.boat.surface_name and memory.boat.surface_name == surface_name) then + return --We only want to generate structures once the players arrive on the island. Otherwise, the following issue happens. 2x2 structures force-generate nearby chunks. But if the island has many structures, that could cause a domino effect of chunk-generation, lagging the game. + -- Since this change, this function has little conceptual reason to be an on_tick function, but it makes sense to run it a few ticks after you teleport to the island, so it can stay one for now. + end + local surface = game.surfaces[surface_name] local structures = destination.dynamic_data.structures_waiting_to_be_placed