From 2c7fbd6ba2c09b8e304ba5e7f8808bfb252aac87 Mon Sep 17 00:00:00 2001 From: Aleksandr Bushuev Date: Sat, 20 Jun 2026 13:54:09 +0500 Subject: [PATCH] [SHUD]: Added config parser destructor for tests purpose --- code/cgame/cg_draw.c | 2 +- code/cgame/cg_main.c | 2 +- code/cgame/cg_ospconfig.c | 2 +- code/cgame/cg_superhud.c | 2 - code/cgame/cg_superhud_configparser.c | 91 ++++++++++-- code/cgame/cg_superhud_private.h | 4 +- code/tests/test_cg_superhud_configparser.cxx | 140 +++++++++++++------ tools/astyle.conf | 2 - 8 files changed, 175 insertions(+), 70 deletions(-) diff --git a/code/cgame/cg_draw.c b/code/cgame/cg_draw.c index 51fd2ced..9c40625b 100644 --- a/code/cgame/cg_draw.c +++ b/code/cgame/cg_draw.c @@ -1930,7 +1930,7 @@ qboolean CG_DrawIntermission(void) return CG_DrawOldScoreboard(); } -void CG_OSPDrawIntermission() +void CG_OSPDrawIntermission(void) { int i; diff --git a/code/cgame/cg_main.c b/code/cgame/cg_main.c index 9731f09e..f98f0492 100644 --- a/code/cgame/cg_main.c +++ b/code/cgame/cg_main.c @@ -1575,7 +1575,7 @@ CG_BuildSpectatorString ======================= */ -void CG_BuildSpectatorString() +void CG_BuildSpectatorString(void) { int i; cg.spectatorList[0] = 0; diff --git a/code/cgame/cg_ospconfig.c b/code/cgame/cg_ospconfig.c index 7b5fea5e..88bfb52d 100644 --- a/code/cgame/cg_ospconfig.c +++ b/code/cgame/cg_ospconfig.c @@ -12,7 +12,7 @@ qboolean CG_OSPIsGameTypeCA(int gametype) return gametype >= GT_CA ? qtrue : qfalse; } -qboolean CG_OSPIsGameTypeFreeze() +qboolean CG_OSPIsGameTypeFreeze(void) { return cgs.gametype == GT_TEAM && cgs.osp.gameTypeFreeze; } diff --git a/code/cgame/cg_superhud.c b/code/cgame/cg_superhud.c index 525e9ed2..87c20739 100644 --- a/code/cgame/cg_superhud.c +++ b/code/cgame/cg_superhud.c @@ -415,7 +415,6 @@ void CG_SHUDEventChat(const char* message) void CG_SHUDEventTeamChat(const char* message) { - int len = 0; char* loc_start; char* loc_end; char* p; @@ -485,7 +484,6 @@ void CG_SHUDEventTeamChat(const char* message) continue; } *p++ = *message++; - len++; } *p = 0; diff --git a/code/cgame/cg_superhud_configparser.c b/code/cgame/cg_superhud_configparser.c index 7475bb83..a97eb5ad 100644 --- a/code/cgame/cg_superhud_configparser.c +++ b/code/cgame/cg_superhud_configparser.c @@ -35,7 +35,7 @@ static superhudConfigParseStatus_t CG_SHUDConfigCommandParseHlSize(configFileInf static superhudConfigParseStatus_t CG_SHUDConfigCommandParseStyle(configFileInfo_t* finfo, superhudConfig_t* config); static superhudConfigParseStatus_t CG_SHUDConfigCommandParseColor2(configFileInfo_t* finfo, superhudConfig_t* config); -static superHUDConfigCommand_t superHUDConfigItemCommands[] = +static const superHUDConfigCommand_t superHUDConfigItemCommands[] = { { "alignh", CG_SHUDConfigCommandParseAlighH }, { "alignv", CG_SHUDConfigCommandParseAlighV }, @@ -67,9 +67,11 @@ static superHUDConfigCommand_t superHUDConfigItemCommands[] = { "visflags", CG_SHUDConfigCommandParseVisFlags}, { "hlsize", CG_SHUDConfigCommandParseHlSize }, { "style", CG_SHUDConfigCommandParseStyle }, - { NULL, NULL, NULL }, + { NULL, NULL }, }; +qboolean is_shud_parser_initialized = qfalse; + #define CG_SHUD_CONFIG_INFO_IS_TEXT_CHARACTER(CCC) \ ((CCC >= 'a' && CCC <= 'z') \ || (CCC >= 'A' && CCC <= 'Z') \ @@ -97,8 +99,14 @@ static superHUDConfigCommand_t superHUDConfigItemCommands[] = #define SHUD_CONFIG_ITEMS_DICT_SIZE 256 +typedef struct superHUDConfigItemCommandsDictItem_s +{ + const superHUDConfigCommand_t* command; + struct superHUDConfigItemCommandsDictItem_s* next; +} superHUDConfigItemCommandsDictItem_t; + static superhudElementDictMember_t* superHUDConfigItemElementsDict[SHUD_CONFIG_ITEMS_DICT_SIZE]; -static superHUDConfigCommand_t* superHUDConfigItemCommandsDict[SHUD_CONFIG_ITEMS_DICT_SIZE]; +static superHUDConfigItemCommandsDictItem_t* superHUDConfigItemCommandsDict[SHUD_CONFIG_ITEMS_DICT_SIZE]; const superHUDConfigElement_t* CG_SHUDFindConfigElementItem(const char* name) { @@ -115,13 +123,17 @@ const superHUDConfigElement_t* CG_SHUDFindConfigElementItem(const char* name) const superHUDConfigCommand_t* CG_SHUDFindConfigCommandItem(const char* name) { - const superHUDConfigCommand_t* target = superHUDConfigItemCommandsDict[Com_GenerateHashValue(name, SHUD_CONFIG_ITEMS_DICT_SIZE)]; + superHUDConfigItemCommandsDictItem_t* target = superHUDConfigItemCommandsDict[Com_GenerateHashValue(name, SHUD_CONFIG_ITEMS_DICT_SIZE)]; - while (target && Q_stricmp(name, target->name)) + while (target && target->command && Q_stricmp(name, target->command->name)) { target = target->next; } - return target; + if (target && target->command) + { + return target->command; + } + return NULL; } /* @@ -1323,21 +1335,21 @@ const superhudConfigParseCommand_t CG_SHUDFileInfoGetCommandItem(configFileInfo_ /* * Инициализация парсера - * No need to free allocated memory as object will be destroyed only when cgame.qvm die */ void CG_SHUDParserInit(void) { int i = 0; - static qboolean initialized = qfalse; const superHUDConfigElement_t* e; const superHUDConfigElement_t* root; - - if (initialized) + if (is_shud_parser_initialized) { return; } + memset(superHUDConfigItemElementsDict, 0, sizeof(superhudElementDictMember_t*)*SHUD_CONFIG_ITEMS_DICT_SIZE); + memset(superHUDConfigItemCommandsDict, 0, sizeof(superHUDConfigItemCommandsDictItem_t*)*SHUD_CONFIG_ITEMS_DICT_SIZE); + CG_SHUDAvailableElementsInit(); root = CG_SHUDAvailableElementsGet(); @@ -1379,8 +1391,8 @@ void CG_SHUDParserInit(void) i = 0; while (superHUDConfigItemCommands[i].name) { - superHUDConfigCommand_t** target = NULL; - superHUDConfigCommand_t* collision = NULL; + superHUDConfigItemCommandsDictItem_t** target = NULL; + superHUDConfigItemCommandsDictItem_t* collision = NULL; unsigned long hash = Com_GenerateHashValue(superHUDConfigItemCommands[i].name, SHUD_CONFIG_ITEMS_DICT_SIZE); @@ -1388,7 +1400,10 @@ void CG_SHUDParserInit(void) target = &superHUDConfigItemCommandsDict[hash]; if (*target == NULL) { - *target = &superHUDConfigItemCommands[i]; + *target = Z_Malloc(sizeof(superHUDConfigItemCommandsDictItem_t)); + OSP_MEMORY_CHECK(*target); + (*target)->command = &superHUDConfigItemCommands[i]; + (*target)->next = NULL; } else { @@ -1398,12 +1413,58 @@ void CG_SHUDParserInit(void) { collision = collision->next; } - collision->next = &superHUDConfigItemCommands[i]; + collision->next = Z_Malloc(sizeof(superHUDConfigItemCommandsDictItem_t)); + OSP_MEMORY_CHECK(collision->next); + collision->next->command = &superHUDConfigItemCommands[i]; + collision->next->next = NULL; } ++i; } - initialized = qtrue; + is_shud_parser_initialized = qtrue; +} + +/* + * Разрушение парсера + */ +void CG_SHUDParserTeardown(void) +{ + int i; + + for (i = 0; i < SHUD_CONFIG_ITEMS_DICT_SIZE; ++i) + { + if (superHUDConfigItemElementsDict[i]) + { + superhudElementDictMember_t* next = NULL; + superhudElementDictMember_t* tmp; + next = superHUDConfigItemElementsDict[i]; + //free collisions too + while (next) + { + tmp = next; + next = next->next; + Z_Free(tmp); + } + superHUDConfigItemElementsDict[i] = NULL; + } + + if (superHUDConfigItemCommandsDict[i]) + { + superHUDConfigItemCommandsDictItem_t* next = NULL; + superHUDConfigItemCommandsDictItem_t* tmp; + next = superHUDConfigItemCommandsDict[i]; + //free collisions too + while (next) + { + tmp = next; + next = next->next; + Z_Free(tmp); + } + superHUDConfigItemCommandsDict[i] = NULL; + } + } + + is_shud_parser_initialized = qfalse; } static superhudConfigParseStatus_t CG_SHUDConfigCommandParseStyle(configFileInfo_t* finfo, superhudConfig_t* config) diff --git a/code/cgame/cg_superhud_private.h b/code/cgame/cg_superhud_private.h index d3b20baa..6e9b657a 100644 --- a/code/cgame/cg_superhud_private.h +++ b/code/cgame/cg_superhud_private.h @@ -302,11 +302,10 @@ typedef struct superhudElement_s } superhudElement_t; -typedef struct superHUDConfigCommand_s +typedef struct { const char* name; superhudConfigParseStatus_t (*parse)(configFileInfo_t* finfo, superhudConfig_t* config); - struct superHUDConfigCommand_s* next; } superHUDConfigCommand_t; typedef struct @@ -330,6 +329,7 @@ typedef struct }while(0) void CG_SHUDParserInit(void); +void CG_SHUDParserTeardown(void); const superHUDConfigElement_t* CG_SHUDFindConfigElementItem(const char* name); const superHUDConfigCommand_t* CG_SHUDFindConfigCommandItem(const char* name); diff --git a/code/tests/test_cg_superhud_configparser.cxx b/code/tests/test_cg_superhud_configparser.cxx index e163cbb1..75f7927c 100644 --- a/code/tests/test_cg_superhud_configparser.cxx +++ b/code/tests/test_cg_superhud_configparser.cxx @@ -3,20 +3,6 @@ #include "../cgame/cg_superhud_private.h" #include "../qcommon/qcommon.h" -namespace -{ - bool initialized = false; - void shud_test_init() - { - if (initialized) return; - Com_InitZoneMemory(); - CG_SHUDParserInit(); - initialized = true; - } - -} - - TEST_CASE("Test SuperHUD: test split config to lines", "[cgame][CG_SHUDConfigFileSplitToLines]") { const char *config0 = ""; @@ -25,7 +11,8 @@ TEST_CASE("Test SuperHUD: test split config to lines", "[cgame][CG_SHUDConfigFil qboolean result; configFileInfo_t info{}; - shud_test_init(); + Com_InitZoneMemory(); + CG_SHUDParserInit(); result = CG_SHUDFileInfoInit(&info, config0); CHECK(result == qfalse); @@ -76,16 +63,20 @@ TEST_CASE("Test SuperHUD: test split config to lines", "[cgame][CG_SHUDConfigFil CHECK(info.last_line->size == 8); CHECK(strcmp(info.last_line->line, " line333") == 0); CG_SHUDFileInfoTeardown(&info); + + CG_SHUDParserTeardown(); } TEST_CASE("Test SuperHUD: find element in dictonary", "[cgame][cg_superhud_configparser]") { - shud_test_init(); + Com_InitZoneMemory(); + CG_SHUDParserInit(); auto result = CG_SHUDFindConfigElementItem("fragmessage"); REQUIRE(result); CHECK(std::strcmp(result->name, "fragmessage") == 0); + CG_SHUDParserTeardown(); } TEST_CASE("Test SuperHUD: get element from config", "[cgame][cg_superhud_configparser]") @@ -100,7 +91,8 @@ TEST_CASE("Test SuperHUD: get element from config", "[cgame][cg_superhud_configp qboolean result; configFileInfo_t info{}; - shud_test_init(); + Com_InitZoneMemory(); + CG_SHUDParserInit(); // no elements result = CG_SHUDFileInfoInit(&info, config0); @@ -162,6 +154,7 @@ TEST_CASE("Test SuperHUD: get element from config", "[cgame][cg_superhud_configp CHECK(std::strcmp(elemResult.item->name, "!default") == 0); CG_SHUDFileInfoTeardown(&info); + CG_SHUDParserTeardown(); } TEST_CASE("Test SuperHUD: get command from config", "[cgame][cg_superhud_configparser]") @@ -174,7 +167,8 @@ TEST_CASE("Test SuperHUD: get command from config", "[cgame][cg_superhud_configp qboolean result; configFileInfo_t info{}; - shud_test_init(); + Com_InitZoneMemory(); + CG_SHUDParserInit(); // default element result = CG_SHUDFileInfoInit(&info, config1); @@ -227,7 +221,7 @@ TEST_CASE("Test SuperHUD: get command from config", "[cgame][cg_superhud_configp CHECK(comResult.status == SUPERHUD_CONFIG_WRONG_COMMAND_NAME); CG_SHUDFileInfoTeardown(&info); - + CG_SHUDParserTeardown(); } TEST_CASE("Test SuperHUD: parse COLOR command", "[cgame][cg_superhud_configparser]") @@ -243,7 +237,8 @@ TEST_CASE("Test SuperHUD: parse COLOR command", "[cgame][cg_superhud_configparse qboolean result; configFileInfo_t info{}; - shud_test_init(); + Com_InitZoneMemory(); + CG_SHUDParserInit(); SECTION("TEI") { @@ -376,6 +371,7 @@ TEST_CASE("Test SuperHUD: parse COLOR command", "[cgame][cg_superhud_configparse } CG_SHUDFileInfoTeardown(&info); + CG_SHUDParserTeardown(); } TEST_CASE("Test SuperHUD: parse ALIGNH command", "[cgame][cg_superhud_configparser]") @@ -389,7 +385,8 @@ TEST_CASE("Test SuperHUD: parse ALIGNH command", "[cgame][cg_superhud_configpars qboolean result; configFileInfo_t info{}; - shud_test_init(); + Com_InitZoneMemory(); + CG_SHUDParserInit(); { superhudConfig_t config{}; @@ -483,6 +480,7 @@ TEST_CASE("Test SuperHUD: parse ALIGNH command", "[cgame][cg_superhud_configpars } CG_SHUDFileInfoTeardown(&info); + CG_SHUDParserTeardown(); } TEST_CASE("Test SuperHUD: parse ALIGNV command", "[cgame][cg_superhud_configparser]") @@ -496,7 +494,8 @@ TEST_CASE("Test SuperHUD: parse ALIGNV command", "[cgame][cg_superhud_configpars qboolean result; configFileInfo_t info{}; - shud_test_init(); + Com_InitZoneMemory(); + CG_SHUDParserInit(); { superhudConfig_t config{}; @@ -590,6 +589,7 @@ TEST_CASE("Test SuperHUD: parse ALIGNV command", "[cgame][cg_superhud_configpars } CG_SHUDFileInfoTeardown(&info); + CG_SHUDParserTeardown(); } TEST_CASE("Test SuperHUD: parse ANGLES command", "[cgame][cg_superhud_configparser]") @@ -602,7 +602,8 @@ TEST_CASE("Test SuperHUD: parse ANGLES command", "[cgame][cg_superhud_configpars qboolean result; configFileInfo_t info{}; - shud_test_init(); + Com_InitZoneMemory(); + CG_SHUDParserInit(); { superhudConfig_t config{}; @@ -703,6 +704,7 @@ TEST_CASE("Test SuperHUD: parse ANGLES command", "[cgame][cg_superhud_configpars } CG_SHUDFileInfoTeardown(&info); + CG_SHUDParserTeardown(); } TEST_CASE("Test SuperHUD: parse BGCOLOR command", "[cgame][cg_superhud_configparser]") @@ -713,7 +715,8 @@ TEST_CASE("Test SuperHUD: parse BGCOLOR command", "[cgame][cg_superhud_configpar qboolean result; configFileInfo_t info{}; - shud_test_init(); + Com_InitZoneMemory(); + CG_SHUDParserInit(); { superhudConfig_t config{}; @@ -765,6 +768,7 @@ TEST_CASE("Test SuperHUD: parse BGCOLOR command", "[cgame][cg_superhud_configpar } CG_SHUDFileInfoTeardown(&info); + CG_SHUDParserTeardown(); } TEST_CASE("Test SuperHUD: parse DIRECTION command", "[cgame][cg_superhud_configparser]") @@ -778,7 +782,8 @@ TEST_CASE("Test SuperHUD: parse DIRECTION command", "[cgame][cg_superhud_configp qboolean result; configFileInfo_t info{}; - shud_test_init(); + Com_InitZoneMemory(); + CG_SHUDParserInit(); { superhudConfig_t config{}; @@ -895,6 +900,7 @@ TEST_CASE("Test SuperHUD: parse DIRECTION command", "[cgame][cg_superhud_configp } CG_SHUDFileInfoTeardown(&info); + CG_SHUDParserTeardown(); } TEST_CASE("Test SuperHUD: parse DOUBLEBAR command", "[cgame][cg_superhud_configparser]") @@ -904,7 +910,8 @@ TEST_CASE("Test SuperHUD: parse DOUBLEBAR command", "[cgame][cg_superhud_configp qboolean result; configFileInfo_t info{}; - shud_test_init(); + Com_InitZoneMemory(); + CG_SHUDParserInit(); superhudConfig_t config{}; @@ -927,6 +934,7 @@ TEST_CASE("Test SuperHUD: parse DOUBLEBAR command", "[cgame][cg_superhud_configp CHECK(config.doublebar.isSet == qtrue); CG_SHUDFileInfoTeardown(&info); + CG_SHUDParserTeardown(); } TEST_CASE("Test SuperHUD: parse FADE command", "[cgame][cg_superhud_configparser]") @@ -937,7 +945,8 @@ TEST_CASE("Test SuperHUD: parse FADE command", "[cgame][cg_superhud_configparser qboolean result; configFileInfo_t info{}; - shud_test_init(); + Com_InitZoneMemory(); + CG_SHUDParserInit(); { superhudConfig_t config{}; @@ -992,6 +1001,7 @@ TEST_CASE("Test SuperHUD: parse FADE command", "[cgame][cg_superhud_configparser } CG_SHUDFileInfoTeardown(&info); + CG_SHUDParserTeardown(); } TEST_CASE("Test SuperHUD: parse FADEDELAY command", "[cgame][cg_superhud_configparser]") @@ -1002,7 +1012,8 @@ TEST_CASE("Test SuperHUD: parse FADEDELAY command", "[cgame][cg_superhud_configp qboolean result; configFileInfo_t info{}; - shud_test_init(); + Com_InitZoneMemory(); + CG_SHUDParserInit(); { superhudConfig_t config{}; @@ -1050,6 +1061,7 @@ TEST_CASE("Test SuperHUD: parse FADEDELAY command", "[cgame][cg_superhud_configp } CG_SHUDFileInfoTeardown(&info); + CG_SHUDParserTeardown(); } TEST_CASE("Test SuperHUD: parse FILL command", "[cgame][cg_superhud_configparser]") @@ -1059,7 +1071,8 @@ TEST_CASE("Test SuperHUD: parse FILL command", "[cgame][cg_superhud_configparser qboolean result; configFileInfo_t info{}; - shud_test_init(); + Com_InitZoneMemory(); + CG_SHUDParserInit(); superhudConfig_t config{}; @@ -1082,6 +1095,7 @@ TEST_CASE("Test SuperHUD: parse FILL command", "[cgame][cg_superhud_configparser CHECK(config.fill.isSet == qtrue); CG_SHUDFileInfoTeardown(&info); + CG_SHUDParserTeardown(); } TEST_CASE("Test SuperHUD: parse FONT command", "[cgame][cg_superhud_configparser]") @@ -1093,7 +1107,8 @@ TEST_CASE("Test SuperHUD: parse FONT command", "[cgame][cg_superhud_configparser qboolean result; configFileInfo_t info{}; - shud_test_init(); + Com_InitZoneMemory(); + CG_SHUDParserInit(); { superhudConfig_t config{}; @@ -1164,6 +1179,7 @@ TEST_CASE("Test SuperHUD: parse FONT command", "[cgame][cg_superhud_configparser } CG_SHUDFileInfoTeardown(&info); + CG_SHUDParserTeardown(); } TEST_CASE("Test SuperHUD: parse FONTSIZE command", "[cgame][cg_superhud_configparser]") @@ -1175,7 +1191,8 @@ TEST_CASE("Test SuperHUD: parse FONTSIZE command", "[cgame][cg_superhud_configpa qboolean result; configFileInfo_t info{}; - shud_test_init(); + Com_InitZoneMemory(); + CG_SHUDParserInit(); { superhudConfig_t config{}; @@ -1248,6 +1265,7 @@ TEST_CASE("Test SuperHUD: parse FONTSIZE command", "[cgame][cg_superhud_configpa } CG_SHUDFileInfoTeardown(&info); + CG_SHUDParserTeardown(); } TEST_CASE("Test SuperHUD: parse IMAGE command", "[cgame][cg_superhud_configparser]") @@ -1259,7 +1277,8 @@ TEST_CASE("Test SuperHUD: parse IMAGE command", "[cgame][cg_superhud_configparse qboolean result; configFileInfo_t info{}; - shud_test_init(); + Com_InitZoneMemory(); + CG_SHUDParserInit(); { superhudConfig_t config{}; @@ -1330,6 +1349,7 @@ TEST_CASE("Test SuperHUD: parse IMAGE command", "[cgame][cg_superhud_configparse } CG_SHUDFileInfoTeardown(&info); + CG_SHUDParserTeardown(); } TEST_CASE("Test SuperHUD: parse IMAGETC command", "[cgame][cg_superhud_configparser]") @@ -1340,7 +1360,8 @@ TEST_CASE("Test SuperHUD: parse IMAGETC command", "[cgame][cg_superhud_configpar qboolean result; configFileInfo_t info{}; - shud_test_init(); + Com_InitZoneMemory(); + CG_SHUDParserInit(); { superhudConfig_t config{}; @@ -1391,6 +1412,7 @@ TEST_CASE("Test SuperHUD: parse IMAGETC command", "[cgame][cg_superhud_configpar } CG_SHUDFileInfoTeardown(&info); + CG_SHUDParserTeardown(); } TEST_CASE("Test SuperHUD: parse ITTEAM command", "[cgame][cg_superhud_configparser]") @@ -1406,7 +1428,8 @@ TEST_CASE("Test SuperHUD: parse ITTEAM command", "[cgame][cg_superhud_configpars qboolean result; configFileInfo_t info{}; - shud_test_init(); + Com_InitZoneMemory(); + CG_SHUDParserInit(); { superhudConfig_t config{}; @@ -1568,6 +1591,7 @@ TEST_CASE("Test SuperHUD: parse ITTEAM command", "[cgame][cg_superhud_configpars } CG_SHUDFileInfoTeardown(&info); + CG_SHUDParserTeardown(); } TEST_CASE("Test SuperHUD: parse MARGINS command", "[cgame][cg_superhud_configparser]") @@ -1578,7 +1602,8 @@ TEST_CASE("Test SuperHUD: parse MARGINS command", "[cgame][cg_superhud_configpar qboolean result; configFileInfo_t info{}; - shud_test_init(); + Com_InitZoneMemory(); + CG_SHUDParserInit(); { superhudConfig_t config{}; @@ -1629,6 +1654,7 @@ TEST_CASE("Test SuperHUD: parse MARGINS command", "[cgame][cg_superhud_configpar } CG_SHUDFileInfoTeardown(&info); + CG_SHUDParserTeardown(); } TEST_CASE("Test SuperHUD: parse MODEL command", "[cgame][cg_superhud_configparser]") @@ -1640,7 +1666,8 @@ TEST_CASE("Test SuperHUD: parse MODEL command", "[cgame][cg_superhud_configparse qboolean result; configFileInfo_t info{}; - shud_test_init(); + Com_InitZoneMemory(); + CG_SHUDParserInit(); { superhudConfig_t config{}; @@ -1711,6 +1738,7 @@ TEST_CASE("Test SuperHUD: parse MODEL command", "[cgame][cg_superhud_configparse } CG_SHUDFileInfoTeardown(&info); + CG_SHUDParserTeardown(); } TEST_CASE("Test SuperHUD: parse MONOSPACE command", "[cgame][cg_superhud_configparser]") @@ -1720,7 +1748,8 @@ TEST_CASE("Test SuperHUD: parse MONOSPACE command", "[cgame][cg_superhud_configp qboolean result; configFileInfo_t info{}; - shud_test_init(); + Com_InitZoneMemory(); + CG_SHUDParserInit(); superhudConfig_t config{}; @@ -1743,6 +1772,7 @@ TEST_CASE("Test SuperHUD: parse MONOSPACE command", "[cgame][cg_superhud_configp CHECK(config.monospace.isSet == qtrue); CG_SHUDFileInfoTeardown(&info); + CG_SHUDParserTeardown(); } TEST_CASE("Test SuperHUD: parse OFFSET command", "[cgame][cg_superhud_configparser]") @@ -1753,7 +1783,8 @@ TEST_CASE("Test SuperHUD: parse OFFSET command", "[cgame][cg_superhud_configpars qboolean result; configFileInfo_t info{}; - shud_test_init(); + Com_InitZoneMemory(); + CG_SHUDParserInit(); { superhudConfig_t config{}; @@ -1803,6 +1834,7 @@ TEST_CASE("Test SuperHUD: parse OFFSET command", "[cgame][cg_superhud_configpars } CG_SHUDFileInfoTeardown(&info); + CG_SHUDParserTeardown(); } TEST_CASE("Test SuperHUD: parse TEXT command", "[cgame][cg_superhud_configparser]") @@ -1814,7 +1846,8 @@ TEST_CASE("Test SuperHUD: parse TEXT command", "[cgame][cg_superhud_configparser qboolean result; configFileInfo_t info{}; - shud_test_init(); + Com_InitZoneMemory(); + CG_SHUDParserInit(); { superhudConfig_t config{}; @@ -1885,6 +1918,7 @@ TEST_CASE("Test SuperHUD: parse TEXT command", "[cgame][cg_superhud_configparser } CG_SHUDFileInfoTeardown(&info); + CG_SHUDParserTeardown(); } TEST_CASE("Test SuperHUD: parse TEXTALIGN command", "[cgame][cg_superhud_configparser]") @@ -1898,7 +1932,8 @@ TEST_CASE("Test SuperHUD: parse TEXTALIGN command", "[cgame][cg_superhud_configp qboolean result; configFileInfo_t info{}; - shud_test_init(); + Com_InitZoneMemory(); + CG_SHUDParserInit(); { superhudConfig_t config{}; @@ -1992,6 +2027,7 @@ TEST_CASE("Test SuperHUD: parse TEXTALIGN command", "[cgame][cg_superhud_configp } CG_SHUDFileInfoTeardown(&info); + CG_SHUDParserTeardown(); } TEST_CASE("Test SuperHUD: parse TEXTOFFSET command", "[cgame][cg_superhud_configparser]") @@ -2002,7 +2038,8 @@ TEST_CASE("Test SuperHUD: parse TEXTOFFSET command", "[cgame][cg_superhud_config qboolean result; configFileInfo_t info{}; - shud_test_init(); + Com_InitZoneMemory(); + CG_SHUDParserInit(); { superhudConfig_t config{}; @@ -2051,6 +2088,7 @@ TEST_CASE("Test SuperHUD: parse TEXTOFFSET command", "[cgame][cg_superhud_config } CG_SHUDFileInfoTeardown(&info); + CG_SHUDParserTeardown(); } TEST_CASE("Test SuperHUD: parse TEXTSTYLE command", "[cgame][cg_superhud_configparser]") @@ -2061,7 +2099,8 @@ TEST_CASE("Test SuperHUD: parse TEXTSTYLE command", "[cgame][cg_superhud_configp qboolean result; configFileInfo_t info{}; - shud_test_init(); + Com_InitZoneMemory(); + CG_SHUDParserInit(); { superhudConfig_t config{}; @@ -2109,6 +2148,7 @@ TEST_CASE("Test SuperHUD: parse TEXTSTYLE command", "[cgame][cg_superhud_configp } CG_SHUDFileInfoTeardown(&info); + CG_SHUDParserTeardown(); } TEST_CASE("Test SuperHUD: parse TIME command", "[cgame][cg_superhud_configparser]") @@ -2119,7 +2159,8 @@ TEST_CASE("Test SuperHUD: parse TIME command", "[cgame][cg_superhud_configparser qboolean result; configFileInfo_t info{}; - shud_test_init(); + Com_InitZoneMemory(); + CG_SHUDParserInit(); { superhudConfig_t config{}; @@ -2167,6 +2208,7 @@ TEST_CASE("Test SuperHUD: parse TIME command", "[cgame][cg_superhud_configparser } CG_SHUDFileInfoTeardown(&info); + CG_SHUDParserTeardown(); } TEST_CASE("Test SuperHUD: parse VISFLAGS command", "[cgame][cg_superhud_configparser]") @@ -2177,7 +2219,8 @@ TEST_CASE("Test SuperHUD: parse VISFLAGS command", "[cgame][cg_superhud_configpa qboolean result; configFileInfo_t info{}; - shud_test_init(); + Com_InitZoneMemory(); + CG_SHUDParserInit(); // Tests disbled as I don't know what visflags is // @@ -2228,6 +2271,7 @@ TEST_CASE("Test SuperHUD: parse VISFLAGS command", "[cgame][cg_superhud_configpa } CG_SHUDFileInfoTeardown(&info); + CG_SHUDParserTeardown(); } TEST_CASE("Test SuperHUD: parse HLSIZE command", "[cgame][cg_superhud_configparser]") @@ -2238,7 +2282,8 @@ TEST_CASE("Test SuperHUD: parse HLSIZE command", "[cgame][cg_superhud_configpars qboolean result; configFileInfo_t info{}; - shud_test_init(); + Com_InitZoneMemory(); + CG_SHUDParserInit(); { superhudConfig_t config{}; @@ -2286,6 +2331,7 @@ TEST_CASE("Test SuperHUD: parse HLSIZE command", "[cgame][cg_superhud_configpars } CG_SHUDFileInfoTeardown(&info); + CG_SHUDParserTeardown(); } TEST_CASE("Test SuperHUD: parse HLCOLOR command", "[cgame][cg_superhud_configparser]") @@ -2296,7 +2342,8 @@ TEST_CASE("Test SuperHUD: parse HLCOLOR command", "[cgame][cg_superhud_configpar qboolean result; configFileInfo_t info{}; - shud_test_init(); + Com_InitZoneMemory(); + CG_SHUDParserInit(); { superhudConfig_t config{}; @@ -2347,5 +2394,6 @@ TEST_CASE("Test SuperHUD: parse HLCOLOR command", "[cgame][cg_superhud_configpar } CG_SHUDFileInfoTeardown(&info); + CG_SHUDParserTeardown(); } diff --git a/tools/astyle.conf b/tools/astyle.conf index 79f63921..e1a8343f 100644 --- a/tools/astyle.conf +++ b/tools/astyle.conf @@ -1,7 +1,5 @@ ---style=ansi --indent-switches --indent-namespaces ---pad-oper --pad-header --unpad-paren --align-pointer=type