Added ignorenick and ignoretext client commands from Q2Pro.

This commit is contained in:
Knightmare66 2020-06-29 02:20:11 -04:00
parent 60427a58c3
commit 28ba96e804
5 changed files with 424 additions and 22 deletions

View file

@ -180,6 +180,11 @@ cvar_t *loc_here;
cvar_t *loc_there; cvar_t *loc_there;
#endif // LOC_SUPPORT #endif // LOC_SUPPORT
// Chat Ignore from R1Q2/Q2Pro
chatIgnore_t cl_chatNickIgnores;
chatIgnore_t cl_chatTextIgnores;
// end R1Q2/Q2Pro Chat Ignore
client_static_t cls; client_static_t cls;
client_state_t cl; client_state_t cl;
@ -187,14 +192,7 @@ centity_t cl_entities[MAX_EDICTS];
entity_state_t cl_parse_entities[MAX_PARSE_ENTITIES]; entity_state_t cl_parse_entities[MAX_PARSE_ENTITIES];
qboolean local_initialized = false;
float ClampCvar( float min, float max, float value )
{
if ( value < min ) return min;
if ( value > max ) return max;
return value;
}
//====================================================================== //======================================================================
@ -366,6 +364,353 @@ void CL_Record_f (void)
// the rest of the demo file will be individual frames // the rest of the demo file will be individual frames
} }
//======================================================================
// Chat Ignore from R1Q2/Q2Pro
//======================================================================
/*
===================
CL_FindChatIgnore
===================
*/
chatIgnore_t *CL_FindChatIgnore (chatIgnore_t *ignoreList, const char *match)
{
chatIgnore_t *cur=NULL;
if (!ignoreList || !ignoreList->next) // no list to search
return NULL;
if ( !match || (strlen(match) < 1) ) // no search string
return NULL;
for (cur = ignoreList->next; cur != NULL; cur = cur->next)
{
if ( !cur->text || (strlen(cur->text) < 1) )
continue;
if (!strcmp(cur->text, match))
return cur;
}
return NULL;
}
/*
===================
CL_AddChatIgnore
===================
*/
qboolean CL_AddChatIgnore (chatIgnore_t *ignoreList, const char *add)
{
chatIgnore_t *next=NULL, *newEntry=NULL;
size_t textLen;
if (!ignoreList) // nothing to remove
return false;
if ( !add || (strlen(add) < 1) ) // no string to add
return false;
// Don't add the same ignore twice
if ( CL_FindChatIgnore (ignoreList, add) ) {
Com_Printf ("%s is already in ignore list.\n", add);
return false;
}
next = ignoreList->next; // should be NULL for first entry
textLen = strlen(Cmd_Argv(1))+1;
newEntry = Z_Malloc (sizeof(chatIgnore_t));
newEntry->numHits = 0;
newEntry->text = Z_Malloc (textLen);
Q_strncpyz (newEntry->text, Cmd_Argv(1), textLen);
newEntry->next = next;
ignoreList->next = newEntry;
return true;
}
/*
===================
CL_RemoveChatIgnore
===================
*/
qboolean CL_RemoveChatIgnore (chatIgnore_t *ignoreList, const char *match)
{
chatIgnore_t *cur=NULL, *last=NULL, *next=NULL;
if (!ignoreList || !ignoreList->next) // nothing to remove
return false;
if ( !match || (strlen(match) < 1) ) // no search string
return false;
for (last = ignoreList, cur = ignoreList->next; cur != NULL; last = cur, cur = cur->next)
{
if ( !cur->text || (strlen(cur->text) < 1) )
continue;
if ( !strcmp(match, cur->text) )
{
next = cur->next;
last->next = next;
Z_Free (cur->text);
cur->text = NULL;
Z_Free (cur);
return true;
}
}
Com_Printf ("Can't find ignore filter \"%s\"\n", match);
return false;
}
/*
===================
CL_RemoveAllChatIgnores
===================
*/
void CL_RemoveAllChatIgnores (chatIgnore_t *ignoreList)
{
chatIgnore_t *cur=NULL, *next=NULL;
int count = 0;
if (!ignoreList || !ignoreList->next) // nothing to remove
return;
cur = ignoreList->next;
next = cur->next;
do
{
if (cur->text != NULL) {
Z_Free (cur->text);
cur->text = NULL;
}
next = cur->next;
Z_Free (cur);
cur = next;
count++;
} while (cur != NULL);
ignoreList->next = NULL;
Com_Printf ("Removed %i ignore filter(s).\n", count);
}
/*
===================
CL_ListChatIgnores
===================
*/
void CL_ListChatIgnores (chatIgnore_t *ignoreList)
{
chatIgnore_t *cur=NULL;
if (!ignoreList || !ignoreList->next) // no list to output
return;
Com_Printf ("Current ignore filters:\n");
for (cur = ignoreList->next; cur != NULL; cur = cur->next)
{
if ( !cur->text || (strlen(cur->text) < 1) )
continue;
Com_Printf ("\"%s\" (%i hits)\n", cur->text, cur->numHits);
}
}
/*
===================
CL_IgnoreChatNick_f
===================
*/
void CL_IgnoreChatNick_f (void)
{
qboolean added;
if (Cmd_Argc() < 2) {
Com_Printf ("Usage: ignorenick <nick>\n");
CL_ListChatIgnores (&cl_chatNickIgnores); // output list if no param
return;
}
added = CL_AddChatIgnore (&cl_chatNickIgnores, Cmd_Argv(1));
if (added)
Com_Printf ("%s added to nick ignore list.\n", Cmd_Argv(1));
}
/*
===================
CL_UnIgnoreChatNick_f
===================
*/
void CL_UnIgnoreChatNick_f (void)
{
qboolean removed;
if (Cmd_Argc() < 2) {
Com_Printf ("Usage: unignorenick <nick>\n");
CL_ListChatIgnores (&cl_chatNickIgnores); // output list if no param
return;
}
if ( (Cmd_Argc() == 2) && !strcmp(Cmd_Argv(1), "all") ) {
CL_RemoveAllChatIgnores (&cl_chatNickIgnores);
return;
}
removed = CL_RemoveChatIgnore (&cl_chatNickIgnores, Cmd_Argv(1));
if (removed)
Com_Printf ("%s removed from nick ignore list.\n", Cmd_Argv(1));
}
/*
===================
CL_IgnoreChatText_f
===================
*/
void CL_IgnoreChatText_f (void)
{
qboolean added;
if (Cmd_Argc() < 2) {
Com_Printf ("Usage: ignoretext <text>\n");
CL_ListChatIgnores (&cl_chatTextIgnores); // output list if no param
return;
}
added = CL_AddChatIgnore (&cl_chatTextIgnores, Cmd_Argv(1));
if (added)
Com_Printf ("%s added to text ignore list.\n", Cmd_Argv(1));
}
/*
===================
CL_UnIgnoreChatText_f
===================
*/
void CL_UnIgnoreChatText_f (void)
{
qboolean removed;
if (Cmd_Argc() < 2) {
Com_Printf ("Usage: unignoretext <text>\n");
CL_ListChatIgnores (&cl_chatTextIgnores); // output list if no param
return;
}
if ( (Cmd_Argc() == 2) && !strcmp(Cmd_Argv(1), "all") ) {
CL_RemoveAllChatIgnores (&cl_chatTextIgnores);
return;
}
removed = CL_RemoveChatIgnore (&cl_chatTextIgnores, Cmd_Argv(1));
if (removed)
Com_Printf ("%s removed from text ignore list.\n", Cmd_Argv(1));
}
/*
===================
CL_ChatMatchIgnoreNick
===================
*/
qboolean CL_ChatMatchIgnoreNick (const char *buf, size_t bufSize, const char *nick)
{
size_t nickLen = strlen(nick);
char *string = (char *)buf, *p = NULL;
int idx = 0;
qboolean clanTag;
// Com_Printf ("CL_ChatMatchIgnoreNick: Searching for nick %s in chat message %s\n", nick, buf);
do
{
clanTag = false;
idx++;
// catch nick with ": " following
if ( !strncmp(string, nick, nickLen) && !strncmp(string + nickLen, ": ", 2) )
return true;
if (*string == '(') // catch nick in parenthesis
{
if (!strncmp(string + 1, nick, nickLen) && !strncmp(string + 1 + nickLen, "): ", 3) )
return true;
}
// skip over clan tag in []
if (*string == '[') {
p = strstr(string + 1, "] ");
if (p) {
// Com_Printf ("CL_ChatMatchIgnoreNick: skipping over clan tag\n");
clanTag = true;
string = p + 2;
}
}
}
while ( clanTag && (idx < 2) && (string < (buf + bufSize)) );
return false;
}
/*
===================
CL_CheckforChatIgnore
===================
*/
qboolean CL_CheckForChatIgnore (const char *string)
{
char chatBuf[MSG_STRING_SIZE];
chatIgnore_t *compare=NULL;
if (!cl_chatNickIgnores.next && !cl_chatTextIgnores.next) // nothing in lists to compare
return false;
Q_strncpyz (chatBuf, unformattedString(string), sizeof(chatBuf));
// Com_Printf ("CL_CheckForChatIgnore: scanning chat message \"%s\" for ignore nicks and text\n", chatBuf);
if (cl_chatNickIgnores.next != NULL)
{
for (compare = cl_chatNickIgnores.next; compare != NULL; compare = compare->next)
{
if ( (compare->text != NULL) && (strlen(compare->text) > 0) ) {
if ( CL_ChatMatchIgnoreNick(chatBuf, sizeof(chatBuf), compare->text) ) {
// Com_Printf ("CL_CheckForChatIgnore: filtered nick %s in chat message\n", compare->text);
compare->numHits++;
return true;
}
}
}
}
if (cl_chatTextIgnores.next != NULL)
{
for (compare = cl_chatTextIgnores.next; compare != NULL; compare = compare->next)
{
if ( (compare->text != NULL) && (strlen(compare->text) > 0) ) {
if ( Q_StrScanToken (chatBuf, compare->text, false) ) {
// Com_Printf ("CL_CheckForChatIgnore: filtered text %s in chat message\n", compare->text);
compare->numHits++;
return true;
}
}
}
}
return false;
}
//======================================================================
// end R1Q2/Q2Pro Chat Ignore
//====================================================================== //======================================================================
/* /*
@ -1736,6 +2081,13 @@ void CL_InitLocal (void)
Cmd_AddCommand ("aacskey", CL_AACSkey_f); Cmd_AddCommand ("aacskey", CL_AACSkey_f);
// Chat Ignore from R1Q2/Q2Pro
Cmd_AddCommand ("ignorenick", CL_IgnoreChatNick_f);
Cmd_AddCommand ("unignorenick", CL_UnIgnoreChatNick_f);
Cmd_AddCommand ("ignoretext", CL_IgnoreChatText_f);
Cmd_AddCommand ("unignoretext", CL_UnIgnoreChatText_f);
// end R1Q2/Q2Pro Chat Ignore
#ifdef LOC_SUPPORT // Xile/NiceAss LOC #ifdef LOC_SUPPORT // Xile/NiceAss LOC
Cmd_AddCommand ("loc_add", CL_AddLoc_f); Cmd_AddCommand ("loc_add", CL_AddLoc_f);
Cmd_AddCommand ("loc_del", CL_DeleteLoc_f); Cmd_AddCommand ("loc_del", CL_DeleteLoc_f);
@ -1768,6 +2120,16 @@ void CL_InitLocal (void)
Cmd_AddCommand ("invdrop", NULL); Cmd_AddCommand ("invdrop", NULL);
Cmd_AddCommand ("weapnext", NULL); Cmd_AddCommand ("weapnext", NULL);
Cmd_AddCommand ("weapprev", NULL); Cmd_AddCommand ("weapprev", NULL);
// Chat Ignore from R1Q2/Q2Pro
// Init list pointers
cl_chatNickIgnores.next = NULL;
cl_chatNickIgnores.text = NULL;
cl_chatTextIgnores.next = NULL;
cl_chatTextIgnores.text = NULL;
// end R1Q2/Q2Pro Chat Ignore
local_initialized = true;
} }

View file

@ -657,6 +657,10 @@ void CL_ParsePrint (void)
if (i == PRINT_CHAT) if (i == PRINT_CHAT)
{ {
// Chat Ignore from R1Q2/Q2Pro
if ( CL_CheckForChatIgnore(s) )
return;
S_StartLocalSound ("misc/talk.wav"); S_StartLocalSound ("misc/talk.wav");
// con.ormask = 128; // made redundant by color code // con.ormask = 128; // made redundant by color code

View file

@ -51,6 +51,19 @@ int color8blue (int color8)
//================================================= //=================================================
/*
==========================
ClampCvar
==========================
*/
float ClampCvar (float min, float max, float value)
{
if ( value < min ) return min;
if ( value > max ) return max;
return value;
}
/* /*
========================== ==========================
stringLen stringLen
@ -94,26 +107,33 @@ unformattedString
*/ */
char *unformattedString (const char *string) char *unformattedString (const char *string)
{ {
unsigned i; unsigned int i;
int len; size_t len;
char character; char character;
char *newstring = ""; // char *newstring = "";
static char newstring[MSG_STRING_SIZE];
char addchar[2];
len = strlen (string); len = strlen (string);
newstring[0] = '\0'; // init as blank
for ( i = 0; i < len; i++ ) for ( i = 0; i < len; i++ )
{ {
character = string[i]; character = (string[i] & ~128);
if (character&128) character &= ~128; if ( (character == '^') && (i < len) ) { // skip formatting codes
if (character == '^' && i < len)
{
i++; i++;
continue; continue;
} }
character = string[i];
va("%s%c", newstring, character); if (character < 32) { // skip unprintable chars
continue;
}
// va("%s%c", newstring, character);
addchar[0] = character;
addchar[1] = '\0';
Q_strncatz (newstring, addchar, sizeof(newstring));
} }
return newstring; return newstring;

View file

@ -169,6 +169,21 @@ typedef struct dlhandle_s
#endif // USE_CURL #endif // USE_CURL
// Chat Ignore from R1Q2/Q2Pro
typedef struct chatIgnore_s
{
struct chatIgnore_s *next;
char *text;
int numHits;
} chatIgnore_t;
extern chatIgnore_t cl_chatNickIgnores;
extern chatIgnore_t cl_chatTextIgnores;
qboolean CL_CheckForChatIgnore (const char *string);
// end R1Q2/Q2Pro Chat Ignore
// //
// the client_state_t structure is wiped completely at every // the client_state_t structure is wiped completely at every
// server map change // server map change
@ -544,8 +559,6 @@ extern entity_state_t cl_parse_entities[MAX_PARSE_ENTITIES];
extern netadr_t net_from; extern netadr_t net_from;
extern sizebuf_t net_message; extern sizebuf_t net_message;
float ClampCvar( float min, float max, float value );
// for use with the alt_text_color cvar // for use with the alt_text_color cvar
void CL_TextColor (int colornum, int *red, int *green, int *blue); void CL_TextColor (int colornum, int *red, int *green, int *blue);
qboolean CL_StringSetParams (char modifier, int *red, int *green, int *blue, int *bold, int *shadow, int *italic, int *reset); qboolean CL_StringSetParams (char modifier, int *red, int *green, int *blue, int *bold, int *shadow, int *italic, int *reset);
@ -1091,6 +1104,7 @@ void CL_WidowSplash (vec3_t org);
int color8red (int color8); int color8red (int color8);
int color8green (int color8); int color8green (int color8);
int color8blue (int color8); int color8blue (int color8);
float ClampCvar (float min, float max, float value);
int stringLen (const char *string); int stringLen (const char *string);
int stringLengthExtra (const char *string); int stringLengthExtra (const char *string);
char *unformattedString (const char *string); char *unformattedString (const char *string);

View file

@ -4,7 +4,7 @@ Changes as of v0.20 update 8:
- Added 3840x1600 and 4096x2160 video modes. - Added 3840x1600 and 4096x2160 video modes.
- Added 160Hz and 240Hz refresh rates. - Added 160Hz and 240Hz refresh rates.
- Added support for triple-monitor surround modes via custom resolutions. Monitors must be bound as a single logical display. - Added support for triple-monitor surround modes via custom resolutions. Monitors must be bound as a single logical display.
Keeps all menu/HUD elements on the center screen, set the cvar scr_surroundlayout to 0 to disable this. Keeps all menu/HUD elements on the center screen, set the cvar scr_surroundlayout to 0 to disable this.
@ -18,13 +18,15 @@ Changes as of v0.20 update 8:
- Added support for quake2:// URLs. - Added support for quake2:// URLs.
- Added ignorenick/unignorenick and ignoretext/unignoretext client commands from Q2Pro.
- Added cel shading support. Uses cvars r_celshading to enable, and r_celshading_width for line width (1-10). - Added cel shading support. Uses cvars r_celshading to enable, and r_celshading_width for line width (1-10).
- Added horizontal offset to third-person mode. Offset distance is controlled by cvar cg_thirdperson_offset. - Added horizontal offset to third-person mode. Offset distance is controlled by cvar cg_thirdperson_offset.
- Added font upscaling (with optional blending by Skuller from Q2Pro) for old 128x128 fonts. Use cvar r_font_upscale to enable, - Added font upscaling (with optional blending by Skuller from Q2Pro) for old 128x128 fonts. Use cvar r_font_upscale to enable,
value of 1 is pixel copy, value of 2 enables blending. Requires vid_restart for changes to take effect. value of 1 is pixel copy, value of 2 enables blending. Requires vid_restart for changes to take effect.
- Now reads/writes savegames, config files, demos, etc. to <userprofile>/Saved Games/KMQuake2 on Windows Vista - Now reads/writes savegames, config files, demos, etc. to <userprofile>/Saved Games/KMQuake2 on Windows Vista
and later, and to My Documents/My Games/KMQuake2 on Windows 2000/XP/2003. and later, and to My Documents/My Games/KMQuake2 on Windows 2000/XP/2003.
Autodownloaded files are now written to <userprofile>/Downloads/KMQuake2 on Windows Vista and later, Autodownloaded files are now written to <userprofile>/Downloads/KMQuake2 on Windows Vista and later,