diff --git a/control.lua b/control.lua index 2bc9792..536ceca 100644 --- a/control.lua +++ b/control.lua @@ -148,7 +148,8 @@ end) script.on_event(defines.events.on_research_finished, function(event) local research = event.research - SendBroadcastMsg("Team " .. research.force.name .. " finished research: " .. research.name) + -- TODO: Add a non-mod setting to disable this. + SendBroadcastMsg({"oarc-research-finished", research.force.name, research.name}) end) ---------------------------------------- diff --git a/lib/regrowth_map.lua b/lib/regrowth_map.lua index a37ec37..d51cee9 100644 --- a/lib/regrowth_map.lua +++ b/lib/regrowth_map.lua @@ -114,14 +114,16 @@ function RegrowthDisableSurface(surface_name) storage.rg[surface_name].active = false TableRemoveOneUsingPairs(storage.rg.active_surfaces, surface_name) - -- Make sure indices are reset if needed + -- Make sure indices are reset and the iterator made invalid too if (storage.rg.current_surface == surface_name) then storage.rg.current_surface = nil storage.rg.current_surface_index = 1 + storage.rg.chunk_iter = nil end if (storage.rg.we_current_surface == surface_name) then storage.rg.we_current_surface = nil storage.rg.we_current_surface_index = 1 + storage.rg.we_chunk_iter = nil end if #storage.rg.active_surfaces > 0 then storage.rg.current_surface = storage.rg.active_surfaces[1] @@ -396,6 +398,7 @@ function GetNextChunkAndUpdateIter() -- Make sure we have a valid iterator! if (not storage.rg.chunk_iter or not storage.rg.chunk_iter.valid) then + if game.surfaces[storage.rg.current_surface] == nil then return nil end storage.rg.chunk_iter = game.surfaces[storage.rg.current_surface].get_chunks() end @@ -408,8 +411,12 @@ function GetNextChunkAndUpdateIter() local next_surface_info = GetNextActiveSurface(storage.rg.current_surface_index) storage.rg.current_surface = next_surface_info.surface storage.rg.current_surface_index = next_surface_info.index - storage.rg.chunk_iter = game.surfaces[storage.rg.current_surface].get_chunks() - next_chunk = storage.rg.chunk_iter() + + -- Surface may not exist + if game.surfaces[storage.rg.current_surface] ~= nil then + storage.rg.chunk_iter = game.surfaces[storage.rg.current_surface].get_chunks() + next_chunk = storage.rg.chunk_iter() + end end return next_chunk @@ -421,6 +428,7 @@ function GetNextChunkAndUpdateWorldEaterIter() -- Make sure we have a valid iterator! if (not storage.rg.we_chunk_iter or not storage.rg.we_chunk_iter.valid) then + if game.surfaces[storage.rg.we_current_surface] == nil then return nil end storage.rg.we_chunk_iter = game.surfaces[storage.rg.we_current_surface].get_chunks() end @@ -433,8 +441,12 @@ function GetNextChunkAndUpdateWorldEaterIter() local next_surface_info = GetNextActiveSurface(storage.rg.we_current_surface_index) storage.rg.we_current_surface = next_surface_info.surface storage.rg.we_current_surface_index = next_surface_info.index - storage.rg.we_chunk_iter = game.surfaces[storage.rg.we_current_surface].get_chunks() - next_chunk = storage.rg.we_chunk_iter() + + -- Surface may not exist + if game.surfaces[storage.rg.we_current_surface] ~= nil then + storage.rg.we_chunk_iter = game.surfaces[storage.rg.we_current_surface].get_chunks() + next_chunk = storage.rg.we_chunk_iter() + end end return next_chunk diff --git a/locale/en/locale.cfg b/locale/en/locale.cfg index 28e23d5..3e34a6d 100644 --- a/locale/en/locale.cfg +++ b/locale/en/locale.cfg @@ -393,6 +393,8 @@ oarc-spawn-distance-invalid-msg=Invalid setting! Near spawn min distance is grea oarc-world-eater-invalid-msg=Invalid setting! World eater is enabled but regrowth is not! Disabling world eater. oarc-default-surface-invalid-msg=Invalid setting! Default surface does not exist! Setting to nauvis. +oarc-research-finished=Team __1__ has finished researching __2__! + [entity-name] oarc-linked-chest=OARC Linked Chest oarc-linked-power=OARC Linked Power diff --git a/migrations/oarc-mod-V2.1.10.lua b/migrations/oarc-mod-V2.1.10.lua index 5e0afde..98d7042 100644 --- a/migrations/oarc-mod-V2.1.10.lua +++ b/migrations/oarc-mod-V2.1.10.lua @@ -4,7 +4,31 @@ if storage.ocfg.spawn_general.force_tiles == nil then log("Updating spawn_general config with new 'force_tiles' setting.") end +-- Init OCFG surfaces for other planets if they don't exist. +if (storage.ocfg.surfaces_config["fulgora"] == nil) or + (storage.ocfg.surfaces_config["fulgora"].spawn_config.fill_tile == nil) then + storage.ocfg.surfaces_config["fulgora"] = + { + spawn_config = FULGORA_SPAWN_CONFIG, + starting_items = FULGORA_STARTER_ITEMS + } +end + +-- Refresh the Nauvis config if it is missing the new settings: +if storage.ocfg.surfaces_config["nauvis"].spawn_config.fill_tile == nil then + storage.ocfg.surfaces_config["nauvis"] = { + spawn_config = NAUVIS_SPAWN_CONFIG, + starting_items = NAUVIS_STARTER_ITEMS + } +end + --Make sure new planets get init'd. No harm in running this multiple times. SeparateSpawnsInitPlanets() ---Migrate surface config changes! \ No newline at end of file +-- Block spam. Highhly requested. +game.technology_notifications_enabled = false + +-- New global teleport queue for nil characters. +if storage.nil_character_teleport_queue == nil then + storage.nil_character_teleport_queue = {} +end \ No newline at end of file