diff --git a/Upgrade.lua b/Upgrade.lua index 9b6bc8c..5e1666b 100644 --- a/Upgrade.lua +++ b/Upgrade.lua @@ -5,6 +5,8 @@ local upgrade = {} local constants = require("libs/Constants") local chunkProcessor = require("libs/ChunkProcessor") local mapUtils = require("libs/MapUtils") +local chunkPropertyUtils = require("libs/ChunkUtils") +local baseUtils = require("libs/BaseUtils") -- constants @@ -28,6 +30,13 @@ local TRIPLE_CHUNK_SIZE = constants.TRIPLE_CHUNK_SIZE -- imported functions +local getChunkById = mapUtils.getChunkById +local setChunkBase = chunkPropertyUtils.setChunkBase + +local createBase = baseUtils.createBase +local findNearbyBase = baseUtils.findNearbyBase + + local sFind = string.find local queueGeneratedChunk = mapUtils.queueGeneratedChunk local processPendingChunks = chunkProcessor.processPendingChunks @@ -522,7 +531,26 @@ function upgrade.attempt(universe) global.version = 205 addCommandSet(universe) - game.print("Rampant - Version 2.0.1") + end + if global.version < 206 then + global.version = 206 + + if universe.NEW_ENEMIES then + local tick = game.tick + for chunkId, chunkPack in pairs(universe.chunkToNests) do + local map = chunkPack.map + if map.surface.valid then + local chunk = getChunkById(map, chunkId) + local base = findNearbyBase(map, chunk) + if not base then + base = createBase(map, chunk, tick) + end + setChunkBase(map, chunk, base) + end + end + end + + game.print("Rampant - Version 2.0.2") end return (starting ~= global.version) and global.version diff --git a/changelog.txt b/changelog.txt index 002536f..d02c252 100644 --- a/changelog.txt +++ b/changelog.txt @@ -1,3 +1,9 @@ +--------------------------------------------------------------------------------------------------- +Version: 2.0.2 +Date: 15. 12. 2021 + Bugfixes: + - Fixed base missing in unregisteredEnemyStructure with Rampant already active in a save before enabling new enemies + --------------------------------------------------------------------------------------------------- Version: 2.0.1 Date: 23. 11. 2021 diff --git a/control.lua b/control.lua index 0105c4a..3160741 100644 --- a/control.lua +++ b/control.lua @@ -37,6 +37,9 @@ local RETREAT_SPAWNER_GRAB_RADIUS = constants.RETREAT_SPAWNER_GRAB_RADIUS -- imported functions +local getChunkById = mapUtils.getChunkById +local setChunkBase = chunkPropertyUtils.setChunkBase + local setPointAreaInQuery = queryUtils.setPointAreaInQuery local setPositionInQuery = queryUtils.setPositionInQuery @@ -254,6 +257,7 @@ local function onConfigChanged() universe["ENEMY_SEED"] = settings.startup["rampant--enemySeed"].value universe["ENEMY_VARIATIONS"] = settings.startup["rampant--newEnemyVariations"].value + local usingNewEnemiesAlready = universe["NEW_ENEMIES"] universe["NEW_ENEMIES"] = settings.startup["rampant--newEnemies"].value if universe.NEW_ENEMIES then @@ -292,6 +296,20 @@ local function onConfigChanged() prepMap(universe, surface) end end + if (not usingNewEnemiesAlready) and universe.NEW_ENEMIES then + local tick = game.tick + for chunkId, chunkPack in pairs(universe.chunkToNests) do + local map = chunkPack.map + if map.surface.valid then + local chunk = getChunkById(map, chunkId) + local base = findNearbyBase(map, chunk) + if not base then + base = createBase(map, chunk, tick) + end + setChunkBase(map, chunk, base) + end + end + end end local function onBuild(event) diff --git a/info.json b/info.json index 074baec..7eff974 100644 --- a/info.json +++ b/info.json @@ -1,7 +1,7 @@ { "name" : "Rampant", "factorio_version" : "1.1", - "version" : "2.0.1", + "version" : "2.0.2", "title" : "Rampant", "author" : "Veden", "homepage" : "https://forums.factorio.com/viewtopic.php?f=94&t=31445",