Binary file not shown.
+10
-34
@@ -1,4 +1,3 @@
|
||||
|
||||
---@class DatabaseTables
|
||||
---@field AllZoneNames Array<string> All Zone Names
|
||||
---@field StageZoneNames Array<string> All Stage Zone Names
|
||||
@@ -64,7 +63,6 @@ local Database = {}
|
||||
---@param Logger Logger
|
||||
---@return Database
|
||||
function Database.New(Logger)
|
||||
|
||||
---@type DatabaseTables
|
||||
local tables = {
|
||||
AllZoneNames = {},
|
||||
@@ -167,13 +165,13 @@ function Database.New(Logger)
|
||||
for i, layer in pairs(env.mission.drawings.layers) do
|
||||
if string.lower(layer.name) == "author" then
|
||||
for key, layer_object in pairs(layer.objects) do
|
||||
|
||||
if Spearhead.Util.startswith(layer_object.name, "stagebriefing", true) then
|
||||
--[[
|
||||
TODO: Stage Briefings
|
||||
]]
|
||||
else
|
||||
local inZone = Spearhead.DcsUtil.isPositionInZones(layer_object.mapX, layer_object.mapY, self._tables.MissionZones)
|
||||
local inZone = Spearhead.DcsUtil.isPositionInZones(layer_object.mapX, layer_object.mapY,
|
||||
self._tables.MissionZones)
|
||||
if Spearhead.Util.tableLength(inZone) >= 1 then
|
||||
local name = inZone[1]
|
||||
if name ~= nil then
|
||||
@@ -190,8 +188,6 @@ function Database.New(Logger)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -201,7 +197,6 @@ function Database.New(Logger)
|
||||
for _, stageZoneName in pairs(self._tables.StageZoneNames) do
|
||||
local stageData = self._tables.StageZones[stageZoneName]
|
||||
if stageData then
|
||||
|
||||
-- fill blue sams
|
||||
for _, blueSamStageName in pairs(self._tables.BlueSams) do
|
||||
if Spearhead.DcsUtil.isZoneInZone(blueSamStageName, stageZoneName) == true then
|
||||
@@ -240,6 +235,8 @@ function Database.New(Logger)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
for _, missionZone in pairs(self._tables.MissionZones) do
|
||||
if self._tables.DescriptionsByMission[missionZone] == nil then
|
||||
@@ -253,13 +250,8 @@ function Database.New(Logger)
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
|
||||
for _, farpZoneName in pairs(self._tables.AllFarpZones) do
|
||||
|
||||
for _, airbase in pairs(world.getAirbases()) do
|
||||
|
||||
if airbase:getDesc().category == Airbase.Category.HELIPAD then
|
||||
local name = airbase:getName()
|
||||
|
||||
@@ -304,14 +296,12 @@ function Database.New(Logger)
|
||||
|
||||
|
||||
for _, zoneData in pairs(self._tables.StageZones) do
|
||||
|
||||
local number = zoneData.StageIndex
|
||||
|
||||
for _, cap_route_zone in pairs(self._tables.CapRoutes) do
|
||||
if Spearhead.DcsUtil.isZoneInZone(cap_route_zone, zoneData.StageZoneName) == true then
|
||||
local zone = Spearhead.DcsUtil.getZoneByName(cap_route_zone)
|
||||
if zone then
|
||||
|
||||
---@type CapData
|
||||
local capData = self._tables.CapDataPerStageNumber[number]
|
||||
if capData == nil then
|
||||
@@ -324,9 +314,9 @@ function Database.New(Logger)
|
||||
|
||||
|
||||
if zone.zone_type == Spearhead.DcsUtil.ZoneType.Cilinder then
|
||||
table.insert(capData.routes, { point1 = { x = zone.location.x, z = zone.location.y, y = 0 }, point2 = nil })
|
||||
table.insert(capData.routes,
|
||||
{ point1 = { x = zone.location.x, z = zone.location.y, y = 0 }, point2 = nil })
|
||||
else
|
||||
|
||||
local biggest = nil
|
||||
local biggestA = nil
|
||||
local biggestB = nil
|
||||
@@ -382,10 +372,8 @@ function Database.New(Logger)
|
||||
|
||||
|
||||
return self
|
||||
|
||||
end
|
||||
|
||||
|
||||
local is_group_taken = {}
|
||||
|
||||
local getAvailableGroups = function()
|
||||
@@ -419,8 +407,6 @@ function Database:initAvailableUnits()
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
|
||||
---@private
|
||||
function Database:loadCapUnits()
|
||||
local all_groups = getAvailableCAPGroups()
|
||||
@@ -433,7 +419,7 @@ function Database:loadCapUnits()
|
||||
|
||||
if zone == nil then
|
||||
zone = {
|
||||
location = {x = point.x, y = point.z} ,
|
||||
location = { x = point.x, y = point.z },
|
||||
radius = 4000,
|
||||
name = "temp_zone",
|
||||
verts = {},
|
||||
@@ -503,7 +489,6 @@ end
|
||||
function Database:loadFarpGroups()
|
||||
local all_groups = getAvailableGroups()
|
||||
for _, farpZone in pairs(self._tables.AllFarpZones) do
|
||||
|
||||
if self._tables.FarpZoneData[farpZone] == nil then
|
||||
self._tables.FarpZoneData[farpZone] = {
|
||||
groups = {},
|
||||
@@ -520,10 +505,8 @@ function Database:loadFarpGroups()
|
||||
end
|
||||
|
||||
function Database:loadAirbaseGroups()
|
||||
|
||||
local all_groups = getAvailableGroups()
|
||||
for _, stageZone in pairs(self._tables.StageZones) do
|
||||
|
||||
for _, baseName in pairs(stageZone.AirbaseNames) do
|
||||
local base = Airbase.getByName(baseName)
|
||||
|
||||
@@ -534,7 +517,7 @@ function Database:loadAirbaseGroups()
|
||||
|
||||
if airbaseZone == nil then
|
||||
airbaseZone = {
|
||||
location = {x = point.x, y = point.z} ,
|
||||
location = { x = point.x, y = point.z },
|
||||
radius = 4000,
|
||||
name = "temp_zone",
|
||||
verts = {},
|
||||
@@ -601,7 +584,6 @@ function Database:loadMiscGroupsInStages()
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
function Database:GetDescriptionForMission(missionZoneName)
|
||||
return self._tables.DescriptionsByMission[missionZoneName]
|
||||
end
|
||||
@@ -642,16 +624,15 @@ function Database:getCapRouteInZone(stageNumber, baseName)
|
||||
local stageZoneName = Spearhead.Util.randomFromList(self._tables.StageZonesByNumber[stageNumber]) or "none"
|
||||
local stagezone = Spearhead.DcsUtil.getZoneByName(stageZoneName)
|
||||
if stagezone then
|
||||
|
||||
---@type Airbase?
|
||||
local base = Airbase.getByName(baseName)
|
||||
if base then
|
||||
local closest = nil
|
||||
if stagezone.zone_type == Spearhead.DcsUtil.ZoneType.Cilinder then
|
||||
closest = GetClosestPointOnCircle({ x = stagezone.location.x, z = stagezone.location.y }, stagezone.radius,
|
||||
closest = GetClosestPointOnCircle({ x = stagezone.location.x, z = stagezone.location.y },
|
||||
stagezone.radius,
|
||||
base:getPoint())
|
||||
else
|
||||
|
||||
local closestDistance = -1
|
||||
for _, vert in pairs(stagezone.verts) do
|
||||
local pos = base:getPoint()
|
||||
@@ -676,7 +657,6 @@ function Database:getCapRouteInZone(stageNumber, baseName)
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
---@return Array<string> result a list of stage zone names
|
||||
function Database:getStagezoneNames()
|
||||
return self._tables.StageZoneNames
|
||||
@@ -715,7 +695,6 @@ end
|
||||
---@param stageName string
|
||||
---@return table result airbase Names
|
||||
function Database:getAirbaseNamesInStage(stageName)
|
||||
|
||||
local stageData = self._tables.StageZones[stageName]
|
||||
if not stageData then return {} end
|
||||
|
||||
@@ -735,8 +714,6 @@ function Database:getFarpDataForZone(farpZoneName)
|
||||
return farpData
|
||||
end
|
||||
|
||||
|
||||
|
||||
---@param airbaseName string
|
||||
---@return Array<string>
|
||||
function Database:getCapGroupsAtAirbase(airbaseName)
|
||||
@@ -801,6 +778,5 @@ function Database:GetNewMissionCode()
|
||||
]]
|
||||
end
|
||||
|
||||
|
||||
if not Spearhead then Spearhead = {} end
|
||||
Spearhead.DB = Database
|
||||
|
||||
@@ -208,6 +208,9 @@ GlobalStageManager.printFullOverview = function ()
|
||||
|
||||
local logger = Spearhead.LoggerTemplate.new("StageOverview", "INFO")
|
||||
logger:info("Stage overview:")
|
||||
|
||||
local max = 0
|
||||
local lines = {}
|
||||
for stageIndex, stages in pairs(StagesByIndex) do
|
||||
|
||||
local totalStrike = 0
|
||||
@@ -224,9 +227,23 @@ GlobalStageManager.printFullOverview = function ()
|
||||
totaldead = totaldead + dead
|
||||
totalMissions = totalMissions + strike + dead + bai
|
||||
end
|
||||
logger:info("Stage# " .. tostring(stageIndex).. " | " .. totalStrike .. " strikes | " .. totaldead .. " dead | " .. totalbai .. " BAI | Total:" .. totalMissions)
|
||||
|
||||
local index = tonumber(stageIndex)
|
||||
if index then
|
||||
if index > max then
|
||||
max = index
|
||||
end
|
||||
lines[index] ="Stage# " .. tostring(stageIndex).. " | " .. totalStrike .. " strikes | " .. totaldead .. " dead | " .. totalbai .. " BAI | Total:" .. totalMissions
|
||||
else
|
||||
logger:warn("Stage index is not a number: " .. stageIndex)
|
||||
end
|
||||
end
|
||||
|
||||
for i = 1, max do
|
||||
if lines[i] then
|
||||
logger:info(lines[i])
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
|
||||
+1
-3
@@ -1,6 +1,7 @@
|
||||
|
||||
SpearheadConfig = {
|
||||
|
||||
---DEBUG LOGGING
|
||||
debugEnabled = false, -- default false
|
||||
|
||||
CapConfig = {
|
||||
@@ -60,9 +61,6 @@ SpearheadConfig = {
|
||||
-- Amount of stages that are pre-activated on top of the current active stage.
|
||||
-- In Pre-activated the missions are not listed, but SAMs and Airbase groups are spawned.
|
||||
preactivateStage = 1, -- default 1
|
||||
|
||||
---DEBUG logging. Consider keeping this disabled
|
||||
debugEnabled = false
|
||||
},
|
||||
Persistence = {
|
||||
--- io and lfs cannot be sanitized in the MissionScripting.lua
|
||||
|
||||
Reference in New Issue
Block a user