1
0
mirror of https://github.com/veden/Rampant.git synced 2025-03-17 20:58:35 +02:00

fixed enabling new enemies late in save with Rampant already enabled

This commit is contained in:
Aaron Veden 2021-12-15 20:25:44 -08:00
parent 0681bc05fc
commit 4cdd6ce17e
No known key found for this signature in database
GPG Key ID: FF5990B1C6DD3F84
4 changed files with 54 additions and 2 deletions

View File

@ -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

View File

@ -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

View File

@ -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)

View File

@ -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",