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:
parent
0681bc05fc
commit
4cdd6ce17e
30
Upgrade.lua
30
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
|
||||
|
@ -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
|
||||
|
18
control.lua
18
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)
|
||||
|
Loading…
x
Reference in New Issue
Block a user