compat rhs - fix SUBCSTRING and check_strings.py (#9424)

This commit is contained in:
PabstMirror 2023-09-23 12:40:48 -05:00 committed by GitHub
parent b4940e6fa3
commit bd0dfe4b30
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 34 additions and 29 deletions

View File

@ -3,7 +3,7 @@ class CfgMagazines {
class rhs_mag_9M131M;
class GVAR(mag_9M131M): rhs_mag_9M131M {
scope = 2;
displayName = CSTRING(mag_9M131M_displayName);
displayName = SUBCSTRING(mag_9M131M_displayName);
type = 256;
count = 1;
mass = 55;
@ -13,7 +13,7 @@ class CfgMagazines {
class rhs_mag_9M131F;
class GVAR(mag_9M131F): rhs_mag_9M131F {
scope = 2;
displayName = CSTRING(mag_9M131F_displayName);
displayName = SUBCSTRING(mag_9M131F_displayName);
type = 256;
count = 1;
mass = 55;
@ -23,7 +23,7 @@ class CfgMagazines {
class rhs_mag_9m133;
class GVAR(mag_9m133): rhs_mag_9m133 {
scope = 2;
displayName = CSTRING(mag_9m133_displayName);
displayName = SUBCSTRING(mag_9m133_displayName);
type = 256;
count = 1;
mass = 55;
@ -33,7 +33,7 @@ class CfgMagazines {
class rhs_mag_9m133f;
class GVAR(mag_9m133f): rhs_mag_9m133f {
scope = 2;
displayName = CSTRING(mag_9m133f_displayName);
displayName = SUBCSTRING(mag_9m133f_displayName);
type = 256;
count = 1;
mass = 55;
@ -43,7 +43,7 @@ class CfgMagazines {
class rhs_mag_9m1331;
class GVAR(mag_9m1331): rhs_mag_9m1331 {
scope = 2;
displayName = CSTRING(mag_9m1331_displayName);
displayName = SUBCSTRING(mag_9m1331_displayName);
type = 256;
count = 1;
mass = 55;
@ -53,7 +53,7 @@ class CfgMagazines {
class rhs_mag_9m133m2;
class GVAR(mag_9m133m2): rhs_mag_9m133m2 {
scope = 2;
displayName = CSTRING(mag_9m133m2_displayName);
displayName = SUBCSTRING(mag_9m133m2_displayName);
type = 256;
count = 1;
mass = 55;
@ -63,7 +63,7 @@ class CfgMagazines {
class rhs_mag_PG9V;
class GVAR(mag_PG9V): rhs_mag_PG9V {
scope = 2;
displayName = CSTRING(mag_PG9V_displayName);
displayName = SUBCSTRING(mag_PG9V_displayName);
type = 256;
count = 1;
mass = 80;
@ -73,7 +73,7 @@ class CfgMagazines {
class rhs_mag_PG9N;
class GVAR(mag_PG9N): rhs_mag_PG9N {
scope = 2;
displayName = CSTRING(mag_PG9N_displayName);
displayName = SUBCSTRING(mag_PG9N_displayName);
type = 256;
count = 1;
mass = 80;
@ -83,7 +83,7 @@ class CfgMagazines {
class rhs_mag_PG9VNT;
class GVAR(mag_PG9VNT): rhs_mag_PG9VNT {
scope = 2;
displayName = CSTRING(mag_PG9VNT_displayName);
displayName = SUBCSTRING(mag_PG9VNT_displayName);
type = 256;
count = 1;
mass = 80;
@ -93,7 +93,7 @@ class CfgMagazines {
class rhs_mag_OG9VM;
class GVAR(mag_OG9VM): rhs_mag_OG9VM {
scope = 2;
displayName = CSTRING(mag_OG9VM_displayName);
displayName = SUBCSTRING(mag_OG9VM_displayName);
type = 256;
count = 1;
mass = 80;
@ -103,7 +103,7 @@ class CfgMagazines {
class rhs_mag_OG9V;
class GVAR(mag_OG9V): rhs_mag_OG9V {
scope = 2;
displayName = CSTRING(mag_OG9V_displayName);
displayName = SUBCSTRING(mag_OG9V_displayName);
type = 256;
count = 1;
mass = 80;
@ -113,7 +113,7 @@ class CfgMagazines {
class RHS_mag_VOG30_30;
class GVAR(mag_VOG30_30): RHS_mag_VOG30_30 {
scope = 2;
displayName = CSTRING(mag_VOG30_30_displayName);
displayName = SUBCSTRING(mag_VOG30_30_displayName);
type = 256;
count = 30;
mass = 40;
@ -123,7 +123,7 @@ class CfgMagazines {
class RHS_mag_GPD30_30;
class GVAR(mag_GPD30_30): RHS_mag_GPD30_30 {
scope = 2;
displayName = CSTRING(mag_GPD30_30_displayName);
displayName = SUBCSTRING(mag_GPD30_30_displayName);
type = 256;
count = 30;
mass = 40;
@ -133,7 +133,7 @@ class CfgMagazines {
class RHS_mag_VOG17m_30;
class GVAR(mag_VOG17m_30): RHS_mag_VOG17m_30 {
scope = 2;
displayName = CSTRING(mag_VOG17m_30_displayName);
displayName = SUBCSTRING(mag_VOG17m_30_displayName);
type = 256;
count = 30;
mass = 40;

View File

@ -3,7 +3,7 @@ class CfgMagazines {
class rhs_mag_TOW;
class GVAR(mag_TOW): rhs_mag_TOW {
scope = 2;
displayName = CSTRING(mag_TOW_displayName);
displayName = SUBCSTRING(mag_TOW_displayName);
type = 256;
count = 1;
mass = 200; // Actually should be 440 but ARMA uses weight and volume in the same number
@ -13,7 +13,7 @@ class CfgMagazines {
class rhs_mag_TOWB;
class GVAR(mag_TOWB): rhs_mag_TOWB {
scope = 2;
displayName = CSTRING(mag_TOWB_displayName);
displayName = SUBCSTRING(mag_TOWB_displayName);
type = 256;
count = 1;
mass = 200;
@ -23,7 +23,7 @@ class CfgMagazines {
class rhs_mag_ITOW;
class GVAR(mag_ITOW): rhs_mag_ITOW {
scope = 2;
displayName = CSTRING(mag_ITOW_displayName);
displayName = SUBCSTRING(mag_ITOW_displayName);
type = 256;
count = 1;
mass = 200;
@ -33,7 +33,7 @@ class CfgMagazines {
class rhs_mag_TOW2;
class GVAR(mag_TOW2): rhs_mag_TOW2 {
scope = 2;
displayName = CSTRING(mag_TOW2_displayName);
displayName = SUBCSTRING(mag_TOW2_displayName);
type = 256;
count = 1;
mass = 200;
@ -43,7 +43,7 @@ class CfgMagazines {
class rhs_mag_TOW2A;
class GVAR(mag_TOW2A): rhs_mag_TOW2A {
scope = 2;
displayName = CSTRING(mag_TOW2A_displayName);
displayName = SUBCSTRING(mag_TOW2A_displayName);
type = 256;
count = 1;
mass = 200;
@ -53,7 +53,7 @@ class CfgMagazines {
class rhs_mag_TOW2b;
class GVAR(mag_TOW2b): rhs_mag_TOW2b {
scope = 2;
displayName = CSTRING(mag_TOW2b_displayName);
displayName = SUBCSTRING(mag_TOW2b_displayName);
type = 256;
count = 1;
mass = 200;
@ -63,7 +63,7 @@ class CfgMagazines {
class rhs_mag_TOW2b_aero;
class GVAR(mag_TOW2b_aero): rhs_mag_TOW2b_aero {
scope = 2;
displayName = CSTRING(mag_TOW2b_aero_displayName);
displayName = SUBCSTRING(mag_TOW2b_aero_displayName);
type = 256;
count = 1;
mass = 200;
@ -73,7 +73,7 @@ class CfgMagazines {
class rhs_mag_TOW2bb;
class GVAR(mag_TOW2bb): rhs_mag_TOW2bb {
scope = 2;
displayName = CSTRING(mag_TOW2bb_displayName);
displayName = SUBCSTRING(mag_TOW2bb_displayName);
type = 256;
count = 1;
mass = 200;
@ -84,7 +84,7 @@ class CfgMagazines {
class RHS_48Rnd_40mm_MK19;
class GVAR(48Rnd_40mm_MK19): RHS_48Rnd_40mm_MK19 {
scope = 2;
displayName = CSTRING(48Rnd_40mm_MK19_displayName);
displayName = SUBCSTRING(48Rnd_40mm_MK19_displayName);
type = 256;
count = 48;
mass = 40;
@ -94,7 +94,7 @@ class CfgMagazines {
class RHS_48Rnd_40mm_MK19_M430I;
class GVAR(48Rnd_40mm_MK19_M430I): RHS_48Rnd_40mm_MK19_M430I {
scope = 2;
displayName = CSTRING(48Rnd_40mm_MK19_M430I_displayName);
displayName = SUBCSTRING(48Rnd_40mm_MK19_M430I_displayName);
type = 256;
count = 48;
mass = 40;
@ -104,7 +104,7 @@ class CfgMagazines {
class RHS_48Rnd_40mm_MK19_M430A1;
class GVAR(48Rnd_40mm_MK19_M430A1): RHS_48Rnd_40mm_MK19_M430A1 {
scope = 2;
displayName = CSTRING(48Rnd_40mm_MK19_M430A1_displayName);
displayName = SUBCSTRING(48Rnd_40mm_MK19_M430A1_displayName);
type = 256;
count = 48;
mass = 40;
@ -114,7 +114,7 @@ class CfgMagazines {
class RHS_48Rnd_40mm_MK19_M1001;
class GVAR(48Rnd_40mm_MK19_M1001): RHS_48Rnd_40mm_MK19_M1001 {
scope = 2;
displayName = CSTRING(48Rnd_40mm_MK19_M1001_displayName);
displayName = SUBCSTRING(48Rnd_40mm_MK19_M1001_displayName);
type = 256;
count = 48;
mass = 40;

View File

@ -18,7 +18,8 @@ def getDefinedStrings(filepath):
def getStringUsage(filepath):
selfmodule = (re.search('(addons|optionals)[\W]*([_a-zA-Z0-9]*)', filepath)).group(2)
# print("Checking {0} from {1}".format(filepath,selfmodule))
submodule = (re.search(f'(addons|optionals)[\W]*{selfmodule}[\W]*([_a-zA-Z0-9]*)', filepath)).group(2)
# print(f"Checking {filepath} from {selfmodule} ({submodule})")
fileStrings = []
with open(filepath, 'r') as file:
@ -27,7 +28,7 @@ def getStringUsage(filepath):
srch = re.compile('(STR_ACE_[_a-zA-Z0-9]*)', re.IGNORECASE)
fileStrings = srch.findall(content)
srch = re.compile('[^E][CL]STRING\(([_a-zA-Z0-9]*)\)', re.IGNORECASE)
srch = re.compile('[^EB][CL]STRING\(([_a-zA-Z0-9]*)\)', re.IGNORECASE)
modStrings = srch.findall(content)
for localString in modStrings:
fileStrings.append("STR_ACE_{0}_{1}".format(selfmodule, localString))
@ -37,6 +38,11 @@ def getStringUsage(filepath):
for (exModule, exString) in exStrings:
fileStrings.append("STR_ACE_{0}_{1}".format(exModule, exString))
srch = re.compile('SUB[CL]STRING\(([_a-zA-Z0-9]*)\)')
subStrings = srch.findall(content)
for (subString) in subStrings:
fileStrings.append(f"STR_ACE_{submodule}_{subString}")
srch = re.compile('IGNORE_STRING_WARNING\([\'"]*([_a-zA-Z0-9]*)[\'"]*\)')
ignoreWarnings = srch.findall(content)
@ -73,7 +79,6 @@ def main(argv):
for filename in xml_list:
allDefinedStrings = allDefinedStrings + getDefinedStrings(filename)
for filename in sqf_list:
if ("compat_rhs" in filename): continue #ignore strings in sub-configs for rhs/csw
allUsedStrings = allUsedStrings + getStringUsage(filename)
allDefinedStrings = list(sorted(set(allDefinedStrings)))