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

fixed potential missing base chunk when operating on a chunk that

didn't exist when the entity was created
This commit is contained in:
Aaron Veden 2021-12-11 12:04:53 -08:00
parent ffa52e6c74
commit 58bfbcce6b
No known key found for this signature in database
GPG Key ID: FF5990B1C6DD3F84

View File

@ -444,18 +444,18 @@ function chunkUtils.registerEnemyBaseStructure(map, entity, tick, incomingBase,
for i=1,#chunks do
local chunk = chunks[i]
if (chunk ~= -1) then
if universe.NEW_ENEMIES then
local base = incomingBase
if not base then
base = findNearbyBase(map, chunk)
if not base then
base = createBase(map, chunk, tick)
end
end
setChunkBase(map, chunk, base)
end
if addFunc(map, chunk, entityUnitNumber) then
added = true
if universe.NEW_ENEMIES then
local base = incomingBase
if not base then
base = findNearbyBase(map, chunk)
if not base then
base = createBase(map, chunk, tick)
end
end
setChunkBase(map, chunk, base)
end
end
if (hiveType == "spitter-spawner") or (hiveType == "biter-spawner") then
processNestActiveness(map, chunk)
@ -506,17 +506,17 @@ function chunkUtils.unregisterEnemyBaseStructure(map, entity, damageType, skipCo
end
if removeFunc(map, chunk, entityUnitNumber) then
removed = true
end
if map.universe.NEW_ENEMIES then
local base = getChunkBase(map, chunk)
if damageType and usedBases[base.id] then
usedBases[base.id] = true
local damageTypeName = damageType.name
base.damagedBy[damageTypeName] = (base.damagedBy[damageTypeName] or 0) + 3
base.deathEvents = base.deathEvents + 3
end
if (getEnemyStructureCount(map, chunk) <= 0) then
removeChunkBase(map, chunk, base)
if map.universe.NEW_ENEMIES then
local base = getChunkBase(map, chunk)
if damageType and usedBases[base.id] then
usedBases[base.id] = true
local damageTypeName = damageType.name
base.damagedBy[damageTypeName] = (base.damagedBy[damageTypeName] or 0) + 3
base.deathEvents = base.deathEvents + 3
end
if (getEnemyStructureCount(map, chunk) <= 0) then
removeChunkBase(map, chunk, base)
end
end
end
end