Fixed unit payloads, spread update load from mission update

This commit is contained in:
Pax1601
2023-02-14 22:48:17 +01:00
parent 0564b4b01f
commit 433b4bdf56
13 changed files with 1349 additions and 60 deletions

View File

@@ -1,5 +1,8 @@
Olympus = {}
Olympus.groupIndex = 0
Olympus.groupStep = 40
function Olympus.notify(message, displayFor)
trigger.action.outText(message, displayFor)
end
@@ -18,30 +21,44 @@ function Olympus.setMissionData(arg, time)
end
-- Units tactical data
-- TODO find some way to spread the load of getting this data (split)
local unitsData = {}
local startIndex = Olympus.groupIndex
local endIndex = startIndex + Olympus.groupStep
local index = 0
for groupName, gp in pairs(mist.DBs.groupsByName) do
if groupName ~= nil then
local group = Group.getByName(groupName)
if group ~= nil then
local controller = group:getController()
for index, unit in pairs(group:getUnits()) do
local table = {}
table["targets"] = {}
table["targets"]["visual"] = controller:getDetectedTargets(1)
table["targets"]["radar"] = controller:getDetectedTargets(4)
table["targets"]["rwr"] = controller:getDetectedTargets(16)
table["targets"]["other"] = controller:getDetectedTargets(2, 8, 32)
index = index + 1
if index > startIndex then
if groupName ~= nil then
local group = Group.getByName(groupName)
if group ~= nil then
local controller = group:getController()
for index, unit in pairs(group:getUnits()) do
local table = {}
table["targets"] = {}
table["targets"]["visual"] = controller:getDetectedTargets(1)
table["targets"]["radar"] = controller:getDetectedTargets(4)
table["targets"]["rwr"] = controller:getDetectedTargets(16)
table["targets"]["other"] = controller:getDetectedTargets(2, 8, 32)
table["hasTask"] = controller:hasTask()
table["ammo"] = unit:getAmmo()
table["fuel"] = unit:getFuel()
table["life"] = unit:getLife() / unit:getLife0()
unitsData[unit:getObjectID()] = table
table["hasTask"] = controller:hasTask()
table["ammo"] = unit:getAmmo()
table["fuel"] = unit:getFuel()
table["life"] = unit:getLife() / unit:getLife0()
unitsData[unit:getObjectID()] = table
end
end
end
end
if index == endIndex then
break
end
end
if index ~= endIndex then
Olympus.groupIndex = 0
else
Olympus.groupIndex = endIndex
end
-- Airbases data
@@ -67,7 +84,7 @@ function Olympus.setMissionData(arg, time)
local command = "Olympus.missionData = " .. Olympus.serializeTable(missionData) .. "\n" .. "Olympus.OlympusDLL.setMissionData()"
net.dostring_in("export", command)
return time + 5
return time + 1
end
function Olympus.serializeTable(val, name, skipnewlines, depth)