Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion code/cgame/cg_draw.c
Original file line number Diff line number Diff line change
Expand Up @@ -1930,7 +1930,7 @@ qboolean CG_DrawIntermission(void)
return CG_DrawOldScoreboard();
}

void CG_OSPDrawIntermission()
void CG_OSPDrawIntermission(void)
{
int i;

Expand Down
2 changes: 1 addition & 1 deletion code/cgame/cg_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -1575,7 +1575,7 @@ CG_BuildSpectatorString

=======================
*/
void CG_BuildSpectatorString()
void CG_BuildSpectatorString(void)
{
int i;
cg.spectatorList[0] = 0;
Expand Down
2 changes: 1 addition & 1 deletion code/cgame/cg_ospconfig.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
2 changes: 0 additions & 2 deletions code/cgame/cg_superhud.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -485,7 +484,6 @@ void CG_SHUDEventTeamChat(const char* message)
continue;
}
*p++ = *message++;
len++;
}

*p = 0;
Expand Down
91 changes: 76 additions & 15 deletions code/cgame/cg_superhud_configparser.c
Original file line number Diff line number Diff line change
Expand Up @@ -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 },
Expand Down Expand Up @@ -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') \
Expand Down Expand Up @@ -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)
{
Expand All @@ -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;
}

/*
Expand Down Expand Up @@ -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();
Expand Down Expand Up @@ -1379,16 +1391,19 @@ 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);

/* store in the hash table */
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
{
Expand All @@ -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)
Expand Down
4 changes: 2 additions & 2 deletions code/cgame/cg_superhud_private.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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);

Expand Down
Loading
Loading