From 2513ef25decafe753a87749d6c0dac7eb211f61a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B6rn=20Dahlgren?= Date: Tue, 29 Jun 2021 20:21:08 +0200 Subject: [PATCH] Add optionals to validation tools (#8290) --- optionals/compat_rh_de/CfgAmmo.hpp | 72 ++++++++++++------------ optionals/compat_rh_m4/CfgAmmo.hpp | 2 +- optionals/compat_rh_m4/CfgWeapons.hpp | 4 +- optionals/compat_rh_pdw/CfgWeapons.hpp | 8 +-- optionals/compat_rhs_usf3/CfgGlasses.hpp | 2 +- optionals/tracers/CfgMagazines.hpp | 3 +- tools/check_strings.py | 33 +++++------ tools/config_style_checker.py | 19 ++++--- tools/sqf_validator.py | 15 ++--- 9 files changed, 81 insertions(+), 77 deletions(-) diff --git a/optionals/compat_rh_de/CfgAmmo.hpp b/optionals/compat_rh_de/CfgAmmo.hpp index 2297d89023..73596fa631 100644 --- a/optionals/compat_rh_de/CfgAmmo.hpp +++ b/optionals/compat_rh_de/CfgAmmo.hpp @@ -1,9 +1,9 @@ class CfgAmmo { - class BulletBase; - class RH_50_AE_Ball: BulletBase - { + class BulletBase; + class RH_50_AE_Ball: BulletBase + { ACE_caliber=12.7; ACE_bulletLength=28.194; ACE_bulletMass=21.06; @@ -14,9 +14,9 @@ class CfgAmmo ACE_dragModel=1; ACE_muzzleVelocities[]={360, 398, 420}; ACE_barrelLengths[]={101.6, 152.4, 228.6}; - }; - class RH_454_Casull: BulletBase - { + }; + class RH_454_Casull: BulletBase + { ACE_caliber=11.481; ACE_bulletLength=22.733; ACE_bulletMass=21.06; @@ -27,9 +27,9 @@ class CfgAmmo ACE_dragModel=1; ACE_muzzleVelocities[]={450, 490, 500}; ACE_barrelLengths[]={101.6, 190.5, 228.6}; - }; - class RH_32ACP: BulletBase - { + }; + class RH_32ACP: BulletBase + { ACE_caliber=7.938; ACE_bulletLength=15.494; ACE_bulletMass=4.212; @@ -40,9 +40,9 @@ class CfgAmmo ACE_dragModel=1; ACE_muzzleVelocities[]={282, 300, 320}; ACE_barrelLengths[]={101.6, 127.0, 228.6}; - }; - class RH_45ACP: BulletBase - { + }; + class RH_45ACP: BulletBase + { ACE_caliber=11.481; ACE_bulletLength=17.272; ACE_bulletMass=14.904; @@ -53,9 +53,9 @@ class CfgAmmo ACE_dragModel=1; ACE_muzzleVelocities[]={230, 250, 285}; ACE_barrelLengths[]={101.6, 127.0, 228.6}; - }; - class RH_B_40SW: BulletBase - { + }; + class RH_B_40SW: BulletBase + { ACE_caliber=10.16; ACE_bulletLength=11.354; ACE_bulletMass=8.748; @@ -66,9 +66,9 @@ class CfgAmmo ACE_dragModel=1; ACE_muzzleVelocities[]={360, 380, 400}; ACE_barrelLengths[]={101.6, 152.4, 228.6}; - }; - class RH_44mag_ball: BulletBase - { + }; + class RH_44mag_ball: BulletBase + { ACE_caliber=10.897; ACE_bulletLength=20.422; ACE_bulletMass=12.96; @@ -79,9 +79,9 @@ class CfgAmmo ACE_dragModel=1; ACE_muzzleVelocities[]={360, 390, 420}; ACE_barrelLengths[]={101.6, 190.5, 228.6}; - }; - class RH_357mag_ball: BulletBase - { + }; + class RH_357mag_ball: BulletBase + { ACE_caliber=9.068; ACE_bulletLength=13.741; ACE_bulletMass=8.1; @@ -92,9 +92,9 @@ class CfgAmmo ACE_dragModel=1; ACE_muzzleVelocities[]={490, 510, 535}; ACE_barrelLengths[]={101.6, 152.4, 228.6}; - }; - class RH_762x25: BulletBase - { + }; + class RH_762x25: BulletBase + { ACE_caliber=7.874; ACE_bulletLength=13.856; ACE_bulletMass=5.5728; @@ -105,9 +105,9 @@ class CfgAmmo ACE_dragModel=1; ACE_muzzleVelocities[]={360, 380, 400}; ACE_barrelLengths[]={101.6, 152.4, 228.6}; - }; - class RH_9x18_Ball: BulletBase - { + }; + class RH_9x18_Ball: BulletBase + { ACE_caliber=9.271; ACE_bulletLength=15.494; ACE_bulletMass=6.00048; @@ -118,9 +118,9 @@ class CfgAmmo ACE_dragModel=1; ACE_muzzleVelocities[]={298, 330, 350}; ACE_barrelLengths[]={96.52, 127.0, 228.6}; - }; - class RH_B_9x19_Ball: BulletBase - { + }; + class RH_B_9x19_Ball: BulletBase + { ACE_caliber=9.017; ACE_bulletLength=15.494; ACE_bulletMass=8.0352; @@ -131,9 +131,9 @@ class CfgAmmo ACE_dragModel=1; ACE_muzzleVelocities[]={340, 370, 400}; ACE_barrelLengths[]={101.6, 127.0, 228.6}; - }; - class RH_B_22LR_SD: BulletBase - { + }; + class RH_B_22LR_SD: BulletBase + { ACE_caliber=5.664; ACE_bulletLength=11.43; ACE_bulletMass=2.4624; @@ -144,9 +144,9 @@ class CfgAmmo ACE_dragModel=1; ACE_muzzleVelocities[]={330, 340, 360}; ACE_barrelLengths[]={101.6, 152.4, 228.6}; - }; - class RH_57x28mm: BulletBase - { + }; + class RH_57x28mm: BulletBase + { ACE_caliber=5.69; ACE_bulletLength=12.573; ACE_bulletMass=1.8144; diff --git a/optionals/compat_rh_m4/CfgAmmo.hpp b/optionals/compat_rh_m4/CfgAmmo.hpp index 763d96e3e7..56d392dd00 100644 --- a/optionals/compat_rh_m4/CfgAmmo.hpp +++ b/optionals/compat_rh_m4/CfgAmmo.hpp @@ -111,7 +111,7 @@ class CfgAmmo { ACE_dragModel=7; ACE_muzzleVelocities[]={700, 732, 750, 780}; ACE_barrelLengths[]={304.8, 406.4, 508.0, 609.6}; - }; + }; class RH_762x35_B_FMJ: B_65x39_Caseless { ACE_caliber=7.823; diff --git a/optionals/compat_rh_m4/CfgWeapons.hpp b/optionals/compat_rh_m4/CfgWeapons.hpp index ad612383d1..d3ac2fe4a0 100644 --- a/optionals/compat_rh_m4/CfgWeapons.hpp +++ b/optionals/compat_rh_m4/CfgWeapons.hpp @@ -59,8 +59,8 @@ class CfgWeapons }; class RH_sbr9: Rifle_Base_F { - ACE_barrelTwist=246.38; - ACE_barrelLength=228.6; + ACE_barrelTwist=246.38; + ACE_barrelLength=228.6; }; class RH_M4A6: RH_M4A1_ris { diff --git a/optionals/compat_rh_pdw/CfgWeapons.hpp b/optionals/compat_rh_pdw/CfgWeapons.hpp index 37e7f7ffb4..e435ef131a 100644 --- a/optionals/compat_rh_pdw/CfgWeapons.hpp +++ b/optionals/compat_rh_pdw/CfgWeapons.hpp @@ -1,10 +1,10 @@ class CfgWeapons { - class Rifle_Base_F; - class RH_PDW: Rifle_Base_F - { + class Rifle_Base_F; + class RH_PDW: Rifle_Base_F + { ACE_barrelTwist=177.8; ACE_barrelLength=254.0; - }; + }; }; diff --git a/optionals/compat_rhs_usf3/CfgGlasses.hpp b/optionals/compat_rhs_usf3/CfgGlasses.hpp index 2d2df886ca..696b31dbeb 100644 --- a/optionals/compat_rhs_usf3/CfgGlasses.hpp +++ b/optionals/compat_rhs_usf3/CfgGlasses.hpp @@ -91,7 +91,7 @@ class CfgGlasses { ACE_Protection = 0; ACE_DustPath = QPATHTOEF(goggles,textures\fx\dust\%1.paa); }; - class rhsusf_shemagh_base: G_Combat { + class rhsusf_shemagh_base: G_Combat { ACE_Overlay = ""; ACE_OverlayDirt = ""; ACE_OverlayCracked = ""; diff --git a/optionals/tracers/CfgMagazines.hpp b/optionals/tracers/CfgMagazines.hpp index bd2919631a..df887520e4 100644 --- a/optionals/tracers/CfgMagazines.hpp +++ b/optionals/tracers/CfgMagazines.hpp @@ -1,3 +1,4 @@ +//IGNORE_STRING_WARNING(str_ace_tracers_magazine); #define STRINGS(magazine) author = ECSTRING(common,ACETeam); displayName = CSTRING(magazine) class CfgMagazines { @@ -82,7 +83,7 @@ class CfgMagazines { descriptionShort = CSTRING(100Rnd_580x42_Drum_tracer_yellow_description); }; - // 6.5mm Caseless MX + // 6.5mm Caseless MX class 30Rnd_65x39_caseless_mag; class ACE_30Rnd_65x39_mx_green : 30Rnd_65x39_caseless_mag { ammo = "B_65x39_Caseless_green"; diff --git a/tools/check_strings.py b/tools/check_strings.py index 78ad52b04e..c8e57907e8 100644 --- a/tools/check_strings.py +++ b/tools/check_strings.py @@ -17,7 +17,7 @@ def getDefinedStrings(filepath): return modStrings def getStringUsage(filepath): - selfmodule = (re.search('addons[\W]*([_a-zA-Z0-9]*)', filepath)).group(1) + selfmodule = (re.search('(addons|optionals)[\W]*([_a-zA-Z0-9]*)', filepath)).group(2) # print("Checking {0} from {1}".format(filepath,selfmodule)) fileStrings = [] @@ -51,23 +51,24 @@ def main(argv): allDefinedStrings = [] allUsedStrings = [] - # Allow running from root directory as well as from inside the tools directory - rootDir = "../addons" - if (os.path.exists("addons")): - rootDir = "addons" + for folder in ['addons', 'optionals']: + # Allow running from root directory as well as from inside the tools directory + rootDir = "../" + folder + if (os.path.exists(folder)): + rootDir = folder - for root, dirnames, filenames in os.walk(rootDir): - for filename in fnmatch.filter(filenames, '*.sqf'): - sqf_list.append(os.path.join(root, filename)) - for filename in fnmatch.filter(filenames, '*.cpp'): - sqf_list.append(os.path.join(root, filename)) - for filename in fnmatch.filter(filenames, '*.hpp'): - sqf_list.append(os.path.join(root, filename)) - for filename in fnmatch.filter(filenames, '*.h'): - sqf_list.append(os.path.join(root, filename)) + for root, dirnames, filenames in os.walk(rootDir): + for filename in fnmatch.filter(filenames, '*.sqf'): + sqf_list.append(os.path.join(root, filename)) + for filename in fnmatch.filter(filenames, '*.cpp'): + sqf_list.append(os.path.join(root, filename)) + for filename in fnmatch.filter(filenames, '*.hpp'): + sqf_list.append(os.path.join(root, filename)) + for filename in fnmatch.filter(filenames, '*.h'): + sqf_list.append(os.path.join(root, filename)) - for filename in fnmatch.filter(filenames, '*.xml'): - xml_list.append(os.path.join(root, filename)) + for filename in fnmatch.filter(filenames, '*.xml'): + xml_list.append(os.path.join(root, filename)) for filename in xml_list: allDefinedStrings = allDefinedStrings + getDefinedStrings(filename) diff --git a/tools/config_style_checker.py b/tools/config_style_checker.py index 03d8f222fe..535ae7c58f 100644 --- a/tools/config_style_checker.py +++ b/tools/config_style_checker.py @@ -131,16 +131,17 @@ def main(): parser.add_argument('-m','--module', help='only search specified module addon folder', required=False, default="") args = parser.parse_args() - # Allow running from root directory as well as from inside the tools directory - rootDir = "../addons" - if (os.path.exists("addons")): - rootDir = "addons" + for folder in ['addons', 'optionals']: + # Allow running from root directory as well as from inside the tools directory + rootDir = "../" + folder + if (os.path.exists(folder)): + rootDir = folder - for root, dirnames, filenames in os.walk(rootDir + '/' + args.module): - for filename in fnmatch.filter(filenames, '*.cpp'): - sqf_list.append(os.path.join(root, filename)) - for filename in fnmatch.filter(filenames, '*.hpp'): - sqf_list.append(os.path.join(root, filename)) + for root, dirnames, filenames in os.walk(rootDir + '/' + args.module): + for filename in fnmatch.filter(filenames, '*.cpp'): + sqf_list.append(os.path.join(root, filename)) + for filename in fnmatch.filter(filenames, '*.hpp'): + sqf_list.append(os.path.join(root, filename)) for filename in sqf_list: bad_count = bad_count + check_config_style(filename) diff --git a/tools/sqf_validator.py b/tools/sqf_validator.py index 6686004ac4..c338b2d383 100644 --- a/tools/sqf_validator.py +++ b/tools/sqf_validator.py @@ -165,14 +165,15 @@ def main(): parser.add_argument('-m','--module', help='only search specified module addon folder', required=False, default="") args = parser.parse_args() - # Allow running from root directory as well as from inside the tools directory - rootDir = "../addons" - if (os.path.exists("addons")): - rootDir = "addons" + for folder in ['addons', 'optionals']: + # Allow running from root directory as well as from inside the tools directory + rootDir = "../" + folder + if (os.path.exists(folder)): + rootDir = folder - for root, dirnames, filenames in os.walk(rootDir + '/' + args.module): - for filename in fnmatch.filter(filenames, '*.sqf'): - sqf_list.append(os.path.join(root, filename)) + for root, dirnames, filenames in os.walk(rootDir + '/' + args.module): + for filename in fnmatch.filter(filenames, '*.sqf'): + sqf_list.append(os.path.join(root, filename)) for filename in sqf_list: bad_count = bad_count + check_sqf_syntax(filename)