mirror of
https://github.com/veden/Rampant.git
synced 2025-02-05 13:14:51 +02:00
fixed turrets and hives not being registered when enabling new enemies
in active save
This commit is contained in:
parent
90eae72fe6
commit
5563911634
19
Upgrade.lua
19
Upgrade.lua
@ -7,6 +7,7 @@ local chunkProcessor = require("libs/ChunkProcessor")
|
||||
local mapUtils = require("libs/MapUtils")
|
||||
local chunkPropertyUtils = require("libs/ChunkPropertyUtils")
|
||||
local baseUtils = require("libs/BaseUtils")
|
||||
local chunkUtils = require("libs/ChunkUtils")
|
||||
|
||||
-- constants
|
||||
|
||||
@ -36,6 +37,7 @@ local setChunkBase = chunkPropertyUtils.setChunkBase
|
||||
local createBase = baseUtils.createBase
|
||||
local findNearbyBase = baseUtils.findNearbyBase
|
||||
|
||||
local addBasesToAllEnemyStructures = chunkUtils.addBasesToAllEnemyStructures
|
||||
|
||||
local sFind = string.find
|
||||
local queueGeneratedChunk = mapUtils.queueGeneratedChunk
|
||||
@ -532,22 +534,11 @@ function upgrade.attempt(universe)
|
||||
|
||||
addCommandSet(universe)
|
||||
end
|
||||
if global.version < 206 then
|
||||
global.version = 206
|
||||
if global.version < 207 then
|
||||
global.version = 207
|
||||
|
||||
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
|
||||
addBasesToAllEnemyStructures(universe, game.tick)
|
||||
end
|
||||
|
||||
game.print("Rampant - Version 2.0.4")
|
||||
|
@ -9,6 +9,7 @@ Date: 17. 12. 2021
|
||||
- Fixed adding player to chunk crash
|
||||
- Fixed surface deletion with chunk processor indexing nil
|
||||
- Fixed enemy structures not being counted for faction adaptation
|
||||
- Fixed when new enemies is enabled partway through game that all enemy structures are registered correctly
|
||||
|
||||
---------------------------------------------------------------------------------------------------
|
||||
Version: 2.0.3
|
||||
|
14
control.lua
14
control.lua
@ -37,6 +37,7 @@ local RETREAT_SPAWNER_GRAB_RADIUS = constants.RETREAT_SPAWNER_GRAB_RADIUS
|
||||
|
||||
-- imported functions
|
||||
|
||||
local addBasesToAllEnemyStructures = chunkUtils.addBasesToAllEnemyStructures
|
||||
local getChunkById = mapUtils.getChunkById
|
||||
local setChunkBase = chunkPropertyUtils.setChunkBase
|
||||
|
||||
@ -297,18 +298,7 @@ local function onConfigChanged()
|
||||
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
|
||||
addBasesToAllEnemyStructures(universe, game.tick)
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -69,9 +69,9 @@ local addUtilityCount = chunkPropertyUtils.addUtilityCount
|
||||
local removeUtilityCount = chunkPropertyUtils.removeUtilityCount
|
||||
|
||||
local getPlayerBaseGenerator = chunkPropertyUtils.getPlayerBaseGenerator
|
||||
local getNestCount = chunkPropertyUtils.getNestCount
|
||||
local setRaidNestActiveness = chunkPropertyUtils.setRaidNestActiveness
|
||||
local setNestActiveness = chunkPropertyUtils.setNestActiveness
|
||||
local getChunkById = mapUtils.getChunkById
|
||||
|
||||
local processNestActiveness = chunkPropertyUtils.processNestActiveness
|
||||
|
||||
@ -343,6 +343,56 @@ function chunkUtils.mapScanEnemyChunk(chunk, map, tick)
|
||||
end
|
||||
end
|
||||
|
||||
function chunkUtils.addBasesToAllEnemyStructures(universe, 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
|
||||
for _, map in pairs(universe.maps) do
|
||||
if map.surface.valid then
|
||||
for chunkId in pairs(map.chunkToTurrets) do
|
||||
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
|
||||
for chunkId in pairs(map.chunkToHives) do
|
||||
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
|
||||
for chunkId in pairs(map.chunkToUtilities) do
|
||||
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
|
||||
for chunkId in pairs(map.chunkToTraps) do
|
||||
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
|
||||
|
||||
function chunkUtils.entityForPassScan(map, entity)
|
||||
local overlapArray = getEntityOverlapChunks(map, entity)
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user