Skip to content

Commit

Permalink
Update CG_LoadEmojis
Browse files Browse the repository at this point in the history
Disable cvar if no emojis were found while scanning for them.
Changed cg_chatBoxEmojis default to 0.
  • Loading branch information
Bucky21659 committed May 20, 2020
1 parent 77becb7 commit ef97567
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
10 changes: 8 additions & 2 deletions codemp/cgame/cg_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -2725,14 +2725,20 @@ CG_LoadEmojis
Method that registers all the avaialable emojis
=================
*/
void CG_LoadEmojis() {
static void CG_LoadEmojis(void) {
int emojiExtFNLen, fileCnt, i, inserted = 0;
char* holdChar;
char emojiExtensionListBuf[2048], emoji[MAX_EMOJI_LENGTH + 4] = { 0 };

//get a list of all the available png files in the emoji folder
fileCnt = trap->FS_GetFileList("gfx/emoji", ".png", emojiExtensionListBuf, sizeof(emojiExtensionListBuf));

if (!fileCnt < 1 && cg_chatBoxEmojis.integer) {
trap->Cvar_Set("cg_chatBoxEmojis", "0");
trap->Cvar_Update(&cg_chatBoxEmojis);
return;
}

holdChar = emojiExtensionListBuf;
for (i = 0; i < fileCnt; i++, holdChar += emojiExtFNLen + 1) {
emojiExtFNLen = strlen(holdChar);
Expand All @@ -2750,7 +2756,7 @@ void CG_LoadEmojis() {

//remove file extension
strcpy(emoji, holdChar);
emoji[emojiExtFNLen - 4] = '\0';
COM_StripExtension(emoji, emoji, sizeof(emoji));

//add emoji to the list
Com_sprintf(emojis[inserted].name, sizeof(emojis[inserted].name), ":%s:", emoji);
Expand Down
2 changes: 1 addition & 1 deletion codemp/cgame/cg_xcvar.h
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ XCVAR_DEF( cg_chatBoxLines, "5", NULL, CVAR_ARCHIVE ) //this would be call
XCVAR_DEF( cg_chatBoxHeight, "350", NULL, CVAR_ARCHIVE )
XCVAR_DEF( cg_chatBoxX, "30", NULL, CVAR_ARCHIVE )
XCVAR_DEF( cg_chatBoxCutOffLength, "350", NULL, CVAR_ARCHIVE )
XCVAR_DEF( cg_chatBoxEmojis, "1", NULL, CVAR_ARCHIVE )
XCVAR_DEF( cg_chatBoxEmojis, "0", NULL, CVAR_ARCHIVE_ND )
XCVAR_DEF( cg_hudColors, "0", NULL, CVAR_ARCHIVE )
XCVAR_DEF( cg_tintHud, "1", NULL, CVAR_ARCHIVE )
XCVAR_DEF( cg_drawScore, "2", NULL, CVAR_ARCHIVE ) //score counter on HUD
Expand Down

0 comments on commit ef97567

Please sign in to comment.