Skip to content

Commit

Permalink
settings: refactor theater settings
Browse files Browse the repository at this point in the history
Add the ability to have per airframe payload limits and ato. Also,
extend the ui table to support various unit settings: pressure,
altitude, speed, temperature, and position coordinates format.
  • Loading branch information
jtoppins committed Aug 28, 2023
1 parent 7afd756 commit ff98559
Show file tree
Hide file tree
Showing 12 changed files with 458 additions and 165 deletions.
3 changes: 3 additions & 0 deletions data/DCT/theaters/Caucasus_dctdemo/settings/airframecost.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
cost = {
["FA-18C_hornet"] = 5,
}
3 changes: 3 additions & 0 deletions data/DCT/theaters/Caucasus_dctdemo/settings/ato.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
ato = {
["FA-18C_hornet"] = { "CAS", "cap", "strike", },
}
8 changes: 6 additions & 2 deletions data/DCT/theaters/Caucasus_dctdemo/settings/payloadlimits.cfg
Original file line number Diff line number Diff line change
@@ -1,2 +1,6 @@
aa = 20
ag = 60
payloadlimits = {
["FA-18C_hornet"] = {
aa = 20,
ag = 60,
},
}
13 changes: 5 additions & 8 deletions data/DCT/theaters/Caucasus_dctdemo/settings/ui.cfg
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
gridfmt = {
["Ka-50"] = "dms",
}

ato = {
["F-16C_50"] = {"strike", "cap"},
["A-10A"] = {"cas",},
--["F-5E"] = {"novalidmission",},
ui = {
["FA-18C_hornet"] = {
gridfmt = "dms",
altfmt = "meter",
},
}
119 changes: 119 additions & 0 deletions src/dct/data/playerui.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,119 @@
-- SPDX-License-Identifier: LGPL-3.0

--- Default aircraft-specific settings.

local function UNITS_IMPERIAL_MBAR_DDM()
return {
["gridfmt"] = "ddm",
["pressurefmt"] = "mbar",
}
end

local function UNITS_IMPERIAL_MGRS()
return {
["gridfmt"] = "mgrs",
}
end

local function UNITS_METRIC()
return {
["distfmt"] = "kilometer",
["altfmt"] = "meter",
["speedfmt"] = "kph",
["tempfmt"] = "C",
}
end

local function UNITS_METRIC_HPA()
local u = UNITS_METRIC()
u.pressurefmt = "hpa"
return u
end

local function UNITS_METRIC_INHG()
local u = UNITS_METRIC()
u.pressurefmt = "inhg"
return u
end

local function UNITS_METRIC_MMHG()
local u = UNITS_METRIC()
u.pressurefmt = "mmhg"
return u
end

local function UNITS_METRIC_MMHG_DDM()
local u = UNITS_METRIC()
u.pressurefmt = "mmhg"
u.gridfmt = "ddm"
return u
end

local playeruicfg = {
["A-10A"] = UNITS_IMPERIAL_MGRS(),
["A-10C"] = UNITS_IMPERIAL_MGRS(),
["A-10C_2"] = UNITS_IMPERIAL_MGRS(),
["AH-64D_BLK_II"] = {
gridfmt = "mgrs",
distfmt = "kilometer",
},
["AJS37"] = UNITS_METRIC_HPA(),
["Bf-109K-4"] = UNITS_METRIC_HPA(),
["F-5E-3"] = {
gridfmt = "ddm",
},
["F-14A-95-GR"] = {
gridfmt = "ddm",
},
["F-14A-135-GR"] = {
gridfmt = "ddm",
},
["F-14B"] = {
gridfmt = "ddm",
},
["F-15ESE"] = {
gridfmt = "ddm",
},
["F-16C_50"] = {
gridfmt = "ddm",
},
["FA-18C_hornet"] = {
gridfmt = "ddm",
},
["FW-190A8"] = UNITS_METRIC_HPA(),
["FW-190D9"] = UNITS_METRIC_HPA(),
["I-16"] = UNITS_METRIC_MMHG(),
["Ka-50"] = UNITS_METRIC_MMHG_DDM(),
["Ka-50_3"] = {
gridfmt = "ddm",
},
["M-2000C"] = UNITS_IMPERIAL_MBAR_DDM(),
["Mi-8MT"] = UNITS_METRIC_MMHG_DDM(),
["Mi-24P"] = UNITS_METRIC_MMHG(),
["Mirage-F1BE"] = UNITS_IMPERIAL_MBAR_DDM(),
["Mirage-F1CE"] = UNITS_IMPERIAL_MBAR_DDM(),
["Mirage-F1EE"] = UNITS_IMPERIAL_MBAR_DDM(),
["Mirage-F1M"] = UNITS_IMPERIAL_MBAR_DDM(),
["MiG-15bis"] = UNITS_METRIC_MMHG(),
["MiG-19P"] = UNITS_METRIC_MMHG(),
["MiG-21Bis"] = UNITS_METRIC_MMHG(),
["MiG-29A"] = UNITS_METRIC_MMHG(),
["MiG-29S"] = UNITS_METRIC_MMHG(),
["MiG-29G"] = UNITS_METRIC_INHG(),
["SA342M"] = {
gridfmt = "ddm",
},
["SA342L"] = {
gridfmt = "ddm",
},
["Su-25"] = UNITS_METRIC_MMHG(),
["Su-25T"] = UNITS_METRIC_MMHG(),
["Su-27"] = UNITS_METRIC_MMHG(),
["Su-33"] = UNITS_METRIC_HPA(),
["Yak-52"] = UNITS_METRIC_MMHG(),
["UH-1H"] = {
gridfmt = "ddm",
},
}

return playeruicfg
15 changes: 15 additions & 0 deletions src/dct/data/restrictedweapons.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
-- SPDX-License-Identifier: LGPL-3.0

--- Default restricted weapons.
local enum = require("dct.enum")

return {
["RN-24"] = {
["cost"] = enum.WPNINFCOST,
["category"] = enum.weaponCategory.AG,
},
["RN-28"] = {
["cost"] = enum.WPNINFCOST,
["category"] = enum.weaponCategory.AG,
},
}
17 changes: 16 additions & 1 deletion src/dct/libs/utils.lua
Original file line number Diff line number Diff line change
Expand Up @@ -132,11 +132,26 @@ function utils.not_playergroup(grp)
return not isplayer
end

function utils.check_ato(mlist)
local ntbl = {}

for _, v in pairs(mlist) do
local mtype = enum.missionType[string.upper(v)]

if mtype == nil then
return false, string.format(
"invalid mission type: %s", v)
end
ntbl[mtype] = true
end
return true, ntbl
end

function utils.set_ato(sqdn, flight)
local sqdnato = sqdn:getDescKey("ato")
-- mixed flights are not allowed in DCS
local actype = next(flight:getDescKey("unitTypeCnt"))
local globalato = dct.settings.ui.ato[actype]
local globalato = dct.settings.ato[actype]

if next(sqdnato) ~= nil then
flight:setDescKey("ato", libsutils.shallowclone(sqdnato))
Expand Down
Loading

0 comments on commit ff98559

Please sign in to comment.