mirror of
https://github.com/veden/Rampant.git
synced 2024-12-26 20:54:12 +02:00
FACTO-292: Fixed hives deregister count and hive death
This commit is contained in:
parent
006564faf3
commit
583c3c6094
@ -15,6 +15,8 @@ Version: 3.3.0
|
||||
- Fixed squad creation didn't take into account chunk pathing from nest to squad
|
||||
- Fixed chunk being invalid on unit group finished gathering
|
||||
- Fixed squad being able to teleport short distance when first assembling
|
||||
- Fixed hives didn't properly decrement counts of entities spawned when spawned entites were destroyed
|
||||
- Fixed hives didn't get unregistered properly
|
||||
|
||||
---------------------------------------------------------------------------------------------------
|
||||
Version: 3.2.2
|
||||
|
@ -112,6 +112,7 @@ local scanResourceMap = Processor.scanResourceMap
|
||||
|
||||
local processNests = Processor.processNests
|
||||
local processHives = Processor.processHives
|
||||
local cleanHivesData = Processor.cleanHivesData
|
||||
|
||||
local rallyUnits = Squad.rallyUnits
|
||||
|
||||
@ -983,6 +984,7 @@ script.on_event(defines.events.on_tick,
|
||||
cleanUpMapTables(tick)
|
||||
planning(gameRef.forces.enemy.evolution_factor)
|
||||
processHives(tick)
|
||||
cleanHivesData()
|
||||
elseif (pick == 1) then
|
||||
processPlayers(gameRef.connected_players, tick)
|
||||
elseif (pick == 2) then
|
||||
|
@ -520,6 +520,14 @@ local function unregisterHive(entityUnitNumber, hiveType)
|
||||
else
|
||||
local hiveData = Universe.hiveData[entityUnitNumber]
|
||||
if hiveData then
|
||||
if Universe.hiveDataIterator == entityUnitNumber then
|
||||
Universe.hiveDataIterator = nil
|
||||
end
|
||||
if not Universe.hives[hiveData.hiveId] then
|
||||
Universe.hiveData[entityUnitNumber] = nil
|
||||
return
|
||||
end
|
||||
|
||||
Universe.activeHives[hiveData.hiveId] = hiveData
|
||||
local adjustedHiveType = (
|
||||
(
|
||||
@ -528,7 +536,7 @@ local function unregisterHive(entityUnitNumber, hiveType)
|
||||
)
|
||||
and "nest"
|
||||
) or hiveType
|
||||
hiveData[adjustedHiveType] = hiveData.nest - 1
|
||||
hiveData[adjustedHiveType] = hiveData[adjustedHiveType] - 1
|
||||
if hiveData[adjustedHiveType] < 0 then
|
||||
hiveData[adjustedHiveType] = 0
|
||||
end
|
||||
|
@ -541,6 +541,25 @@ function Processor.processHives(tick)
|
||||
end
|
||||
end
|
||||
|
||||
function Processor.cleanHivesData()
|
||||
local entityId = Universe.hiveDataIterator
|
||||
local hiveData
|
||||
if not entityId then
|
||||
entityId, hiveData = next(Universe.hiveData, nil)
|
||||
else
|
||||
hiveData = Universe.hiveData[entityId]
|
||||
end
|
||||
if not entityId then
|
||||
Universe.hiveDataIterator = nil
|
||||
return
|
||||
end
|
||||
|
||||
Universe.hiveDataIterator = next(Universe.hiveData, entityId)
|
||||
if not Universe.hives[hiveData.id] then
|
||||
Universe.hiveData[entityId] = nil
|
||||
end
|
||||
end
|
||||
|
||||
function Processor.processPendingChunks(tick, flush)
|
||||
local pendingChunks = Universe.pendingChunks
|
||||
local eventId, event = next(pendingChunks, nil)
|
||||
|
@ -535,6 +535,8 @@ function Upgrade.addUniverseProperties()
|
||||
if global.universePropertyVersion < 2 then
|
||||
global.universePropertyVersion = 2
|
||||
addCommandSet()
|
||||
|
||||
Universe.hiveDataIterator = nil
|
||||
end
|
||||
end
|
||||
|
||||
@ -542,8 +544,6 @@ function Upgrade.attempt()
|
||||
if not global.gameVersion then
|
||||
global.gameVersion = 1
|
||||
|
||||
game.forces.enemy.kill_all_units()
|
||||
|
||||
Universe.evolutionLevel = game.forces.enemy.evolution_factor
|
||||
|
||||
Universe.random = game.create_random_generator(Constants.ENEMY_SEED)
|
||||
@ -572,7 +572,17 @@ function Upgrade.attempt()
|
||||
squad.canBeCompressed = 0
|
||||
end
|
||||
|
||||
game.forces.enemy.kill_all_units()
|
||||
|
||||
local lookup = {}
|
||||
for _, map in pairs(Universe.maps) do
|
||||
local entities = map.surface.find_entities_filtered({
|
||||
type = "unit-spawner",
|
||||
force = "enemy"
|
||||
})
|
||||
for i = 1, #entities do
|
||||
lookup[entities[i].unit_number] = true
|
||||
end
|
||||
for _, chunk in pairs(map.processQueue) do
|
||||
chunk[CHUNK_TICK] = 0
|
||||
chunk[BASE_PHEROMONE] = 0
|
||||
@ -582,6 +592,21 @@ function Upgrade.attempt()
|
||||
chunk[KAMIKAZE_PHEROMONE] = 0
|
||||
end
|
||||
end
|
||||
|
||||
for entityId in pairs(Universe.activeHives) do
|
||||
if not lookup[entityId] then
|
||||
Universe.activeHives[entityId] = nil
|
||||
Universe.hives[entityId] = nil
|
||||
end
|
||||
end
|
||||
for entityId in pairs(Universe.hives) do
|
||||
if not lookup[entityId] then
|
||||
Universe.activeHives[entityId] = nil
|
||||
Universe.hives[entityId] = nil
|
||||
end
|
||||
end
|
||||
|
||||
Universe.hiveIterator = nil
|
||||
end
|
||||
end
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user