Skip to content

Commit

Permalink
Handle duplicate classes due to DCS utilizing both upper and lower case
Browse files Browse the repository at this point in the history
  • Loading branch information
zhexu14 authored and rp- committed May 26, 2024
1 parent ff6ebde commit 26d60e4
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 5 deletions.
8 changes: 4 additions & 4 deletions dcs/statics.py
Original file line number Diff line number Diff line change
Expand Up @@ -1164,13 +1164,13 @@ class FarpHide_Dmed(unittype.StaticType):
shape_name = "FarpHide_Dmed"
rate = 3

class Container_40ft(unittype.StaticType):
class Container_40ft_(unittype.StaticType):
id = "container_40ft"
name = "Container 40ft"
shape_name = "container_40ft"
rate = 1

class Container_20ft(unittype.StaticType):
class Container_20ft_(unittype.StaticType):
id = "container_20ft"
name = "Container 20ft"
shape_name = "container_20ft"
Expand Down Expand Up @@ -1538,8 +1538,8 @@ class Freya_Shelter_Concrete(unittype.StaticType):
"FarpHide_Med": Fortification.FarpHide_Med,
"FarpHide_Dsmall": Fortification.FarpHide_Dsmall,
"FarpHide_Dmed": Fortification.FarpHide_Dmed,
"container_40ft": Fortification.Container_40ft,
"container_20ft": Fortification.Container_20ft,
"container_40ft": Fortification.Container_40ft_,
"container_20ft": Fortification.Container_20ft_,
"FlagPole": Fortification.FlagPole,
"warning_board_a": Fortification.Warning_board_a,
"warning_board_b": Fortification.Warning_board_b,
Expand Down
11 changes: 10 additions & 1 deletion tools/pydcs_export.lua
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,17 @@ local function safe_name(name)
return safeName
end

-- DCS will use both capitalized and lower case names for units.
-- Keep track of used class names and suffix duplicate classes with underscore.
local used_class_names = {}
local function safe_class_name(name)
return safe_name(name):gsub("^%l", string.upper)
local safeName = safe_name(name)
local safeClassName = safeName:gsub("^%l", string.upper)
if used_class_names[safeClassName] ~= nil and used_class_names[safeClassName] ~= safeName then
safeClassName = safeClassName .. '_'
end
used_class_names[safeClassName] = safeName
return safeClassName
end

local function safe_display_name(name)
Expand Down

0 comments on commit 26d60e4

Please sign in to comment.