ensure moved NPC data is unique

This commit is contained in:
Lilian Jónsdóttir 2020-10-05 00:35:55 -07:00
parent e52ff856d6
commit 8d1a16c79d

View file

@ -17,9 +17,11 @@ local function moveNPC(homeData)
-- add to in memory table -- add to in memory table
local badWeather = checks.isBadWeatherNPC(npc) local badWeather = checks.isBadWeatherNPC(npc)
if badWeather then if badWeather then
table.insert(common.runtimeData.movedBadWeatherNPCs, homeData) -- table.insert(common.runtimeData.movedBadWeatherNPCs, homeData)
common.runtimeData.disabledBadWeatherNPCs[npc.id] = homeData
else else
table.insert(common.runtimeData.movedNPCs, homeData) -- table.insert(common.runtimeData.movedNPCs, homeData)
common.runtimeData.movedNPCs[npc.id] = homeData
end end
interop.setRuntimeData(common.runtimeData) interop.setRuntimeData(common.runtimeData)
@ -62,9 +64,10 @@ local function disableNPC(npc)
end end
local function putNPCsBack(npcData) local function putNPCsBack(npcData)
for i = #npcData, 1, -1 do -- for i = #npcData, 1, -1 do
-- if npcData[i].npc.object then for id, data in pairs(npcData) do
local data = table.remove(npcData, i) if data.npc.object then
-- local data = table.remove(npcData, i)
log(common.logLevels.medium, "[PROC] Moving %s back outside to %s (%s, %s, %s)", data.npc.object.name, log(common.logLevels.medium, "[PROC] Moving %s back outside to %s (%s, %s, %s)", data.npc.object.name,
data.ogPlace.id, data.ogPosition.x, data.ogPosition.y, data.ogPosition.z) data.ogPlace.id, data.ogPosition.x, data.ogPosition.y, data.ogPosition.z)
@ -78,7 +81,8 @@ local function putNPCsBack(npcData)
position = data.ogPosition, position = data.ogPosition,
orientation = data.ogPlace orientation = data.ogPlace
}) })
-- end npcData[id] = nil
end
end end
-- reset loaded position data -- reset loaded position data
@ -151,9 +155,11 @@ local function checkForMovedOrDisabledNPCs(cell)
-- add to in memory table -- add to in memory table
if badWeather then if badWeather then
table.insert(common.runtimeData.movedBadWeatherNPCs, homeData) -- table.insert(common.runtimeData.movedBadWeatherNPCs, homeData)
common.runtimeData.disabledBadWeatherNPCs[npc.id] = homeData
else else
table.insert(common.runtimeData.movedNPCs, homeData) -- table.insert(common.runtimeData.movedNPCs, homeData)
common.runtimeData.movedNPCs[npc.id] = homeData
end end
end end
end end