mirror of
https://git.code.sf.net/p/quake/quakeforge
synced 2025-01-17 22:50:51 +00:00
Added llist.[ch], a set of general-purpose linked list routines. Added
cl_chat.[ch] to qw to hold advanced chat features, the first of which is the ability to ignore chat messages from annoying players. Some polishing in this area still remains, but the current implementation seems to work.
This commit is contained in:
parent
075f270fcb
commit
9b63402f12
10 changed files with 590 additions and 17 deletions
|
@ -2,10 +2,10 @@ AUTOMAKE_OPTIONS = foreign
|
||||||
SUBDIRS = GL plugin
|
SUBDIRS = GL plugin
|
||||||
includedir = $(prefix)/include/QF
|
includedir = $(prefix)/include/QF
|
||||||
include_HEADERS = bspfile.h cbuf.h cdaudio.h checksum.h clip_hull.h cmd.h \
|
include_HEADERS = bspfile.h cbuf.h cdaudio.h checksum.h clip_hull.h cmd.h \
|
||||||
console.h crc.h csqc.h cvar.h dstring.h draw.h gib.h \
|
console.h crc.h csqc.h cvar.h dstring.h draw.h gib.h hash.h hl.h \
|
||||||
hash.h hl.h idparse.h in_event.h info.h input.h joystick.h \
|
idparse.h in_event.h info.h input.h joystick.h keys.h link.h llist.h \
|
||||||
keys.h link.h locs.h mathlib.h mdfour.h model.h modelgen.h msg.h pak.h \
|
locs.h mathlib.h mdfour.h model.h modelgen.h msg.h pak.h pakfile.h \
|
||||||
pakfile.h pcx.h plugin.h pr_comp.h pr_debug.h pr_obj.h progs.h qargs.h \
|
pcx.h plugin.h pr_comp.h pr_debug.h pr_obj.h progs.h qargs.h qdefs.h \
|
||||||
qdefs.h qendian.h qfplist.h qtypes.h quakefs.h quakeio.h render.h riff.h \
|
qendian.h qfplist.h qtypes.h quakefs.h quakeio.h render.h riff.h \
|
||||||
screen.h sizebuf.h skin.h sound.h spritegn.h sys.h teamplay.h texture.h \
|
screen.h sizebuf.h skin.h sound.h spritegn.h sys.h teamplay.h texture.h \
|
||||||
tga.h uint32.h va.h ver_check.h vid.h view.h wad.h zone.h
|
tga.h uint32.h va.h ver_check.h vid.h view.h wad.h zone.h
|
||||||
|
|
65
include/QF/llist.h
Normal file
65
include/QF/llist.h
Normal file
|
@ -0,0 +1,65 @@
|
||||||
|
/*
|
||||||
|
llist.h
|
||||||
|
|
||||||
|
Linked list functions
|
||||||
|
|
||||||
|
Copyright (C) 2003 Brian Koropoff
|
||||||
|
|
||||||
|
This program is free software; you can redistribute it and/or
|
||||||
|
modify it under the terms of the GNU General Public License
|
||||||
|
as published by the Free Software Foundation; either version 2
|
||||||
|
of the License, or (at your option) any later version.
|
||||||
|
|
||||||
|
This program is distributed in the hope that it will be useful,
|
||||||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||||
|
|
||||||
|
See the GNU General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU General Public License
|
||||||
|
along with this program; if not, write to:
|
||||||
|
|
||||||
|
Free Software Foundation, Inc.
|
||||||
|
59 Temple Place - Suite 330
|
||||||
|
Boston, MA 02111-1307, USA
|
||||||
|
|
||||||
|
$Id$
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef _LLIST_H
|
||||||
|
#define _LLIST_H
|
||||||
|
|
||||||
|
#include "QF/qtypes.h"
|
||||||
|
|
||||||
|
typedef struct llist_node_s {
|
||||||
|
struct llist_s *parent;
|
||||||
|
struct llist_node_s *prev, *next;
|
||||||
|
void *data;
|
||||||
|
} llist_node_t;
|
||||||
|
|
||||||
|
typedef struct llist_s {
|
||||||
|
struct llist_node_s *start, *end, *iter;
|
||||||
|
void (*freedata)(void *element, void *userdata);
|
||||||
|
qboolean (*cmpdata)(const void *element, const void *comparison, void *userdata);
|
||||||
|
void *userdata;
|
||||||
|
} llist_t;
|
||||||
|
|
||||||
|
typedef qboolean (*llist_iterator_t)(void *element, llist_node_t *node);
|
||||||
|
|
||||||
|
#define LLIST_ICAST(x) (llist_iterator_t)(x)
|
||||||
|
#define LLIST_DATA(node, type) ((type *)((node)->data))
|
||||||
|
|
||||||
|
llist_t *llist_new (void (*freedata)(void *element, void *userdata), qboolean (*cmpdata)(const void *element, const void *comparison, void *userdata), void *userdata);
|
||||||
|
void llist_flush (llist_t *list);
|
||||||
|
void llist_delete (llist_t *list);
|
||||||
|
llist_node_t *llist_append (llist_t *list, void *element);
|
||||||
|
llist_node_t *llist_prefix (llist_t *list, void *element);
|
||||||
|
llist_node_t *llist_getnode (llist_t *list, void *element);
|
||||||
|
llist_node_t *llist_insertafter (llist_node_t *ref, void *element);
|
||||||
|
llist_node_t *llist_insertbefore (llist_node_t *ref, void *element);
|
||||||
|
void *llist_remove (llist_node_t *ref);
|
||||||
|
void llist_iterate (llist_t *list, llist_iterator_t iterate);
|
||||||
|
void *llist_find (llist_t *list, void *comparison);
|
||||||
|
llist_node_t *llist_findnode (llist_t *list, void *comparison);
|
||||||
|
|
||||||
|
#endif
|
|
@ -27,10 +27,9 @@ libQFutil_la_LIBADD= libasm.la $(Z_LIBS) $(DL_LIBS)
|
||||||
libQFutil_la_DEPENDENCIES= libasm.la
|
libQFutil_la_DEPENDENCIES= libasm.la
|
||||||
libQFutil_la_SOURCES= \
|
libQFutil_la_SOURCES= \
|
||||||
bspfile.c buildnum.c cbuf.c checksum.c cmd.c crc.c cvar.c dstring.c \
|
bspfile.c buildnum.c cbuf.c checksum.c cmd.c crc.c cvar.c dstring.c \
|
||||||
fendian.c getopt.c getopt1.c hash.c idparse.c info.c link.c mathlib.c \
|
fendian.c getopt.c getopt1.c hash.c idparse.c info.c link.c llist.c \
|
||||||
mdfour.c msg.c pakfile.c pcx.c plugin.c qargs.c qendian.c qfplist.c \
|
mathlib.c mdfour.c msg.c pakfile.c pcx.c plugin.c qargs.c qendian.c \
|
||||||
quakefs.c quakeio.c riff.c sizebuf.c string.c sys.c tga.c va.c \
|
qfplist.c quakefs.c quakeio.c riff.c sizebuf.c string.c sys.c tga.c \
|
||||||
ver_check.c \
|
va.c ver_check.c wad.c zone.c $(fnmatch)
|
||||||
wad.c zone.c $(fnmatch)
|
|
||||||
|
|
||||||
EXTRA_DIST= $(asm_src) $(fnmatch_src)
|
EXTRA_DIST= $(asm_src) $(fnmatch_src)
|
||||||
|
|
238
libs/util/llist.c
Normal file
238
libs/util/llist.c
Normal file
|
@ -0,0 +1,238 @@
|
||||||
|
/*
|
||||||
|
llist.c
|
||||||
|
|
||||||
|
Linked list functions
|
||||||
|
|
||||||
|
Copyright (C) 2003 Brian Koropoff
|
||||||
|
|
||||||
|
This program is free software; you can redistribute it and/or
|
||||||
|
modify it under the terms of the GNU General Public License
|
||||||
|
as published by the Free Software Foundation; either version 2
|
||||||
|
of the License, or (at your option) any later version.
|
||||||
|
|
||||||
|
This program is distributed in the hope that it will be useful,
|
||||||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||||
|
|
||||||
|
See the GNU General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU General Public License
|
||||||
|
along with this program; if not, write to:
|
||||||
|
|
||||||
|
Free Software Foundation, Inc.
|
||||||
|
59 Temple Place - Suite 330
|
||||||
|
Boston, MA 02111-1307, USA
|
||||||
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifdef HAVE_CONFIG_H
|
||||||
|
# include "config.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#include <stdlib.h>
|
||||||
|
|
||||||
|
#include "QF/llist.h"
|
||||||
|
|
||||||
|
static __attribute__ ((unused)) const char rcsid[] =
|
||||||
|
"$Id$";
|
||||||
|
|
||||||
|
static llist_node_t *
|
||||||
|
llist_newnode (llist_t *list, void *data)
|
||||||
|
{
|
||||||
|
llist_node_t *node = calloc (1, sizeof (llist_node_t));
|
||||||
|
node->parent = list;
|
||||||
|
node->data = data;
|
||||||
|
|
||||||
|
return node;
|
||||||
|
}
|
||||||
|
|
||||||
|
llist_t *
|
||||||
|
llist_new (void (*freedata)(void *element, void *userdata), qboolean (*cmpdata)(const void *element, const void *comparison, void *userdata), void *userdata)
|
||||||
|
{
|
||||||
|
llist_t *new = calloc (1, sizeof (llist_t));
|
||||||
|
|
||||||
|
new->freedata = freedata;
|
||||||
|
new->cmpdata = cmpdata;
|
||||||
|
new->userdata = userdata;
|
||||||
|
|
||||||
|
return new;
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
llist_flush (llist_t *list)
|
||||||
|
{
|
||||||
|
llist_node_t *node, *next;
|
||||||
|
|
||||||
|
if (!list)
|
||||||
|
return;
|
||||||
|
|
||||||
|
for (node = list->start; node; node = next) {
|
||||||
|
next = node->next;
|
||||||
|
list->freedata (node->data, list->userdata);
|
||||||
|
free (node);
|
||||||
|
}
|
||||||
|
list->start = list->end = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
llist_delete (llist_t *list)
|
||||||
|
{
|
||||||
|
if (!list)
|
||||||
|
return;
|
||||||
|
|
||||||
|
llist_flush (list);
|
||||||
|
free (list);
|
||||||
|
}
|
||||||
|
|
||||||
|
llist_node_t *
|
||||||
|
llist_append (llist_t *list, void *element)
|
||||||
|
{
|
||||||
|
llist_node_t *node = llist_newnode (list, element);
|
||||||
|
|
||||||
|
if (!list)
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
if (list->end) {
|
||||||
|
list->end->next = node;
|
||||||
|
node->prev = list->end;
|
||||||
|
list->end = node;
|
||||||
|
} else
|
||||||
|
list->start = list->end = node;
|
||||||
|
return node;
|
||||||
|
}
|
||||||
|
|
||||||
|
llist_node_t *
|
||||||
|
llist_prefix (llist_t *list, void *element)
|
||||||
|
{
|
||||||
|
llist_node_t *node = llist_newnode (list, element);
|
||||||
|
|
||||||
|
if (!list)
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
if (list->start) {
|
||||||
|
list->start->prev = node;
|
||||||
|
node->next = list->start;
|
||||||
|
list->start = node;
|
||||||
|
} else
|
||||||
|
list->start = list->end = node;
|
||||||
|
|
||||||
|
return node;
|
||||||
|
}
|
||||||
|
|
||||||
|
llist_node_t *
|
||||||
|
llist_getnode (llist_t *list, void *element)
|
||||||
|
{
|
||||||
|
llist_node_t *node;
|
||||||
|
|
||||||
|
if (!list)
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
for (node = list->start; node; node = node->next)
|
||||||
|
if (node->data == element)
|
||||||
|
return node;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
llist_node_t *
|
||||||
|
llist_insertafter (llist_node_t *ref, void *element)
|
||||||
|
{
|
||||||
|
llist_node_t *node = llist_newnode (ref->parent, element);
|
||||||
|
|
||||||
|
if (!ref)
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
if (ref->next)
|
||||||
|
ref->next->prev = node;
|
||||||
|
else
|
||||||
|
ref->parent->end = node;
|
||||||
|
node->prev = ref;
|
||||||
|
node->next = ref->next;
|
||||||
|
ref->next = node;
|
||||||
|
|
||||||
|
return node;
|
||||||
|
}
|
||||||
|
|
||||||
|
llist_node_t *
|
||||||
|
llist_insertbefore (llist_node_t *ref, void *element)
|
||||||
|
{
|
||||||
|
llist_node_t *node = llist_newnode (ref->parent, element);
|
||||||
|
|
||||||
|
if (!ref)
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
if (ref->prev)
|
||||||
|
ref->prev->next = node;
|
||||||
|
else
|
||||||
|
ref->parent->start = node;
|
||||||
|
node->next = ref;
|
||||||
|
node->prev = ref->prev;
|
||||||
|
ref->prev = node;
|
||||||
|
|
||||||
|
return node;
|
||||||
|
}
|
||||||
|
|
||||||
|
void *
|
||||||
|
llist_remove (llist_node_t *ref)
|
||||||
|
{
|
||||||
|
void *element;
|
||||||
|
|
||||||
|
if (!ref)
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
if (ref == ref->parent->iter)
|
||||||
|
ref->parent->iter = ref->next;
|
||||||
|
if (ref->prev)
|
||||||
|
ref->prev->next = ref->next;
|
||||||
|
else
|
||||||
|
ref->parent->start = ref->next;
|
||||||
|
if (ref->next)
|
||||||
|
ref->next->prev = ref->prev;
|
||||||
|
else
|
||||||
|
ref->parent->end = ref->prev;
|
||||||
|
|
||||||
|
element = ref->data;
|
||||||
|
free (ref);
|
||||||
|
return element;
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
llist_iterate (llist_t *list, llist_iterator_t iterate)
|
||||||
|
{
|
||||||
|
llist_node_t *node;
|
||||||
|
|
||||||
|
if (!list || !list->start)
|
||||||
|
return;
|
||||||
|
for (node = list->start; node; node = list->iter) {
|
||||||
|
list->iter = node->next;
|
||||||
|
if (!iterate (node->data, node))
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
list->iter = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
void *
|
||||||
|
llist_find (llist_t *list, void *comparison)
|
||||||
|
{
|
||||||
|
llist_node_t *node;
|
||||||
|
|
||||||
|
if (!list)
|
||||||
|
return 0;
|
||||||
|
for (node = list->start; node; node = node->next)
|
||||||
|
if (list->cmpdata (node->data, comparison, list->userdata))
|
||||||
|
return node->data;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
llist_node_t *
|
||||||
|
llist_findnode (llist_t *list, void *comparison)
|
||||||
|
{
|
||||||
|
llist_node_t *node;
|
||||||
|
|
||||||
|
if (!list)
|
||||||
|
return 0;
|
||||||
|
for (node = list->start; node; node = node->next)
|
||||||
|
if (list->cmpdata (node->data, comparison, list->userdata))
|
||||||
|
return node;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
AUTOMAKE_OPTIONS= foreign
|
AUTOMAKE_OPTIONS= foreign
|
||||||
|
|
||||||
EXTRA_DIST = \
|
EXTRA_DIST = \
|
||||||
bothdefs.h cl_cam.h cl_demo.h cl_ents.h cl_input.h cl_main.h \
|
bothdefs.h cl_cam.h cl_chat.h cl_demo.h cl_ents.h cl_input.h \
|
||||||
cl_parse.h cl_pred.h cl_skin.h cl_slist.h cl_tent.h client.h \
|
cl_main.h cl_parse.h cl_pred.h cl_skin.h cl_slist.h cl_tent.h \
|
||||||
crudefile.h game.h host.h msg_ucmd.h pmove.h protocol.h \
|
client.h crudefile.h game.h host.h msg_ucmd.h pmove.h protocol.h \
|
||||||
server.h sv_gib.h sv_demo.h sv_pr_cmds.h sv_progs.h
|
server.h sv_gib.h sv_demo.h sv_pr_cmds.h sv_progs.h
|
||||||
|
|
43
qw/include/cl_chat.h
Normal file
43
qw/include/cl_chat.h
Normal file
|
@ -0,0 +1,43 @@
|
||||||
|
/*
|
||||||
|
cl_ignore.h
|
||||||
|
|
||||||
|
Client-side ignore list management
|
||||||
|
|
||||||
|
Copyright (C) 1996-1997 Id Software, Inc.
|
||||||
|
|
||||||
|
This program is free software; you can redistribute it and/or
|
||||||
|
modify it under the terms of the GNU General Public License
|
||||||
|
as published by the Free Software Foundation; either version 2
|
||||||
|
of the License, or (at your option) any later version.
|
||||||
|
|
||||||
|
This program is distributed in the hope that it will be useful,
|
||||||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||||
|
|
||||||
|
See the GNU General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU General Public License
|
||||||
|
along with this program; if not, write to:
|
||||||
|
|
||||||
|
Free Software Foundation, Inc.
|
||||||
|
59 Temple Place - Suite 330
|
||||||
|
Boston, MA 02111-1307, USA
|
||||||
|
|
||||||
|
$Id$
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef _CL_IGNORE_H
|
||||||
|
#define _CL_IGNORE_H
|
||||||
|
|
||||||
|
typedef struct ignore_s {
|
||||||
|
int slot, uid;
|
||||||
|
const char *lastname;
|
||||||
|
} ignore_t;
|
||||||
|
|
||||||
|
qboolean CL_Chat_Allow_Message (const char *str);
|
||||||
|
void CL_Chat_User_Disconnected (int uid);
|
||||||
|
void CL_Chat_Check_Name (const char *name, int slot);
|
||||||
|
void CL_Chat_Flush_Ignores (void);
|
||||||
|
void CL_Chat_Init (void);
|
||||||
|
|
||||||
|
#endif
|
|
@ -111,8 +111,8 @@ client_LIBS= libasm.a $(qf_client_LIBS)
|
||||||
client_libs= libqw_client.a libqw_common.a
|
client_libs= libqw_client.a libqw_common.a
|
||||||
|
|
||||||
libqw_client_a_SOURCES= \
|
libqw_client_a_SOURCES= \
|
||||||
cl_cam.c cl_cmd.c cl_cvar.c cl_demo.c cl_ents.c cl_input.c \
|
cl_cam.c cl_chat.c cl_cmd.c cl_cvar.c cl_demo.c cl_ents.c \
|
||||||
cl_main.c cl_ngraph.c cl_parse.c cl_pred.c \
|
cl_input.c cl_main.c cl_ngraph.c cl_parse.c cl_pred.c \
|
||||||
cl_screen.c cl_skin.c cl_slist.c cl_tent.c cl_view.c \
|
cl_screen.c cl_skin.c cl_slist.c cl_tent.c cl_view.c \
|
||||||
locs.c sbar.c skin.c teamplay.c
|
locs.c sbar.c skin.c teamplay.c
|
||||||
|
|
||||||
|
|
217
qw/source/cl_chat.c
Normal file
217
qw/source/cl_chat.c
Normal file
|
@ -0,0 +1,217 @@
|
||||||
|
/*
|
||||||
|
cl_ignore.c
|
||||||
|
|
||||||
|
Client-side ignore list management
|
||||||
|
|
||||||
|
Copyright (C) 1996-1997 Id Software, Inc.
|
||||||
|
|
||||||
|
This program is free software; you can redistribute it and/or
|
||||||
|
modify it under the terms of the GNU General Public License
|
||||||
|
as published by the Free Software Foundation; either version 2
|
||||||
|
of the License, or (at your option) any later version.
|
||||||
|
|
||||||
|
This program is distributed in the hope that it will be useful,
|
||||||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||||
|
|
||||||
|
See the GNU General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU General Public License
|
||||||
|
along with this program; if not, write to:
|
||||||
|
|
||||||
|
Free Software Foundation, Inc.
|
||||||
|
59 Temple Place - Suite 330
|
||||||
|
Boston, MA 02111-1307, USA
|
||||||
|
|
||||||
|
*/
|
||||||
|
#ifdef HAVE_CONFIG_H
|
||||||
|
# include "config.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
static __attribute__ ((unused)) const char rcsid[] =
|
||||||
|
"$Id$";
|
||||||
|
|
||||||
|
#ifdef HAVE_STRING_H
|
||||||
|
# include <string.h>
|
||||||
|
#endif
|
||||||
|
#ifdef HAVE_STRINGS_H
|
||||||
|
# include <strings.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#include "QF/info.h"
|
||||||
|
#include "QF/dstring.h"
|
||||||
|
#include "QF/llist.h"
|
||||||
|
#include "QF/cmd.h"
|
||||||
|
#include "QF/sys.h"
|
||||||
|
#include "client.h"
|
||||||
|
#include "cl_chat.h"
|
||||||
|
|
||||||
|
llist_t *ignore_list, *dead_ignore_list;
|
||||||
|
|
||||||
|
static void
|
||||||
|
CL_Ignore_Free (void *ele, void *unused)
|
||||||
|
{
|
||||||
|
ignore_t *ig = (ignore_t *) ele;
|
||||||
|
if (ig->lastname)
|
||||||
|
free ((void *)ig->lastname);
|
||||||
|
free (ig);
|
||||||
|
}
|
||||||
|
|
||||||
|
static qboolean
|
||||||
|
CL_Ignore_Compare (const void *ele, const void *cmp, void *unused)
|
||||||
|
{
|
||||||
|
return *(int *)cmp == ((ignore_t *) ele)->uid;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
CL_Ignore_Sanity_Check (void)
|
||||||
|
{
|
||||||
|
static qboolean iterator (ignore_t *ig, llist_node_t *node)
|
||||||
|
{
|
||||||
|
if (cl.players[ig->slot].userid != ig->uid) // We got out of sync somehow
|
||||||
|
llist_remove (node);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
llist_iterate (ignore_list, LLIST_ICAST (iterator));
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
CL_Ignore_f (void)
|
||||||
|
{
|
||||||
|
CL_Ignore_Sanity_Check ();
|
||||||
|
if (Cmd_Argc () == 1) {
|
||||||
|
static qboolean live_iterator (ignore_t *ig, llist_node_t *node)
|
||||||
|
{
|
||||||
|
Sys_Printf ("%5i - %s\n", ig->uid, Info_ValueForKey (cl.players[ig->slot].userinfo, "name"));
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
static qboolean dead_iterator (ignore_t *ig, llist_node_t *node)
|
||||||
|
{
|
||||||
|
Sys_Printf ("%s\n", ig->lastname);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
Sys_Printf (
|
||||||
|
"Users ignored by user id\n"
|
||||||
|
"------------------------\n"
|
||||||
|
);
|
||||||
|
llist_iterate (ignore_list, LLIST_ICAST (live_iterator));
|
||||||
|
Sys_Printf (
|
||||||
|
"\n"
|
||||||
|
"Users ignored by name (not currently connected)\n"
|
||||||
|
"-----------------------------------------------\n"
|
||||||
|
);
|
||||||
|
llist_iterate (dead_ignore_list, LLIST_ICAST (dead_iterator));
|
||||||
|
} else if (Cmd_Argc () == 2) {
|
||||||
|
int i, uid = atoi (Cmd_Argv (1));
|
||||||
|
|
||||||
|
for (i = 0; i < MAX_CLIENTS; i++) {
|
||||||
|
if (cl.players[i].userid == uid) {
|
||||||
|
ignore_t *new = calloc (1, sizeof (ignore_t));
|
||||||
|
new->slot = i;
|
||||||
|
new->uid = uid;
|
||||||
|
llist_append (ignore_list, new);
|
||||||
|
Sys_Printf ("User %i (%s) is now ignored.\n", uid, Info_ValueForKey (cl.players[i].userinfo, "name"));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Sys_Printf ("No user %i present on the server.\n", uid);
|
||||||
|
} else
|
||||||
|
Sys_Printf ("Usage: ignore [userid]\n");
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
CL_Unignore_f (void)
|
||||||
|
{
|
||||||
|
int uid;
|
||||||
|
llist_node_t *node;
|
||||||
|
|
||||||
|
CL_Ignore_Sanity_Check ();
|
||||||
|
if (Cmd_Argc() != 2)
|
||||||
|
Sys_Printf ("usage: unignore userid\n");
|
||||||
|
else {
|
||||||
|
uid = atoi (Cmd_Argv (1));
|
||||||
|
if ((node = llist_findnode (ignore_list, &uid))) {
|
||||||
|
Sys_Printf ("User %i (%s) is no longer ignored.\n", uid, Info_ValueForKey (cl.players[LLIST_DATA (node, ignore_t)->slot].userinfo, "name"));
|
||||||
|
CL_Ignore_Free (llist_remove (node), 0);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
Sys_Printf ("User %i does not exist or is not presently ignored.\n", uid);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
qboolean
|
||||||
|
CL_Chat_Allow_Message (const char *str)
|
||||||
|
{
|
||||||
|
dstring_t *test = dstring_newstr ();
|
||||||
|
qboolean allowed = true;
|
||||||
|
|
||||||
|
static qboolean iterator (ignore_t *ig, llist_node_t *node)
|
||||||
|
{
|
||||||
|
if (cl.players[ig->slot].userid != ig->uid) { // We got out of sync somehow
|
||||||
|
llist_remove (node);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
dsprintf (test, "%s: ", Info_ValueForKey (cl.players[ig->slot].userinfo, "name"));
|
||||||
|
if (!strncmp (test->str, str, sizeof (test->str))) {
|
||||||
|
return allowed = false;
|
||||||
|
} else
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
llist_iterate (ignore_list, LLIST_ICAST (iterator));
|
||||||
|
return allowed;
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
CL_Chat_User_Disconnected (int uid)
|
||||||
|
{
|
||||||
|
ignore_t *ig;
|
||||||
|
|
||||||
|
CL_Ignore_Sanity_Check ();
|
||||||
|
|
||||||
|
if ((ig = llist_remove (llist_findnode (ignore_list, &uid)))) {
|
||||||
|
if (ig->lastname)
|
||||||
|
free ((void *)ig->lastname);
|
||||||
|
ig->lastname = strdup (Info_ValueForKey (cl.players[ig->slot].userinfo, "name"));
|
||||||
|
llist_append (dead_ignore_list, ig);
|
||||||
|
Sys_Printf ("Ignored user %i (%s) left the server. Now ignoring by name...\n", ig->uid, ig->lastname);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
CL_Chat_Check_Name (const char *name, int slot)
|
||||||
|
{
|
||||||
|
ignore_t *found = 0;
|
||||||
|
|
||||||
|
static qboolean iterator (ignore_t *ig, llist_node_t *node)
|
||||||
|
{
|
||||||
|
if (!strcmp (ig->lastname, name)) {
|
||||||
|
found = ig;
|
||||||
|
return false;
|
||||||
|
} else
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
llist_iterate (dead_ignore_list, LLIST_ICAST (iterator));
|
||||||
|
if (found) {
|
||||||
|
found->slot = slot;
|
||||||
|
found->uid = cl.players[slot].userid;
|
||||||
|
llist_append (ignore_list, llist_remove (llist_getnode (dead_ignore_list, found)));
|
||||||
|
Sys_Printf ("User %i (%s) is using an ignored name. Now ignoring by user id...\n", found->uid, found->lastname);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
CL_Chat_Flush_Ignores (void)
|
||||||
|
{
|
||||||
|
llist_flush (ignore_list);
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
CL_Chat_Init (void)
|
||||||
|
{
|
||||||
|
ignore_list = llist_new (CL_Ignore_Free, CL_Ignore_Compare, 0);
|
||||||
|
dead_ignore_list = llist_new (CL_Ignore_Free, CL_Ignore_Compare, 0);
|
||||||
|
|
||||||
|
Cmd_AddCommand ("ignore", CL_Ignore_f, "Ignores chat and name-change messages from a user.");
|
||||||
|
Cmd_AddCommand ("unignore", CL_Unignore_f, "Removes a previously ignored user from the ignore list.");
|
||||||
|
}
|
|
@ -88,6 +88,7 @@ static __attribute__ ((unused)) const char rcsid[] =
|
||||||
#include "bothdefs.h"
|
#include "bothdefs.h"
|
||||||
#include "buildnum.h"
|
#include "buildnum.h"
|
||||||
#include "cl_cam.h"
|
#include "cl_cam.h"
|
||||||
|
#include "cl_chat.h"
|
||||||
#include "cl_demo.h"
|
#include "cl_demo.h"
|
||||||
#include "cl_ents.h"
|
#include "cl_ents.h"
|
||||||
#include "cl_input.h"
|
#include "cl_input.h"
|
||||||
|
@ -342,6 +343,7 @@ CL_Connect_f (void)
|
||||||
server = Cmd_Argv (1);
|
server = Cmd_Argv (1);
|
||||||
|
|
||||||
CL_Disconnect ();
|
CL_Disconnect ();
|
||||||
|
CL_Chat_Flush_Ignores ();
|
||||||
|
|
||||||
strncpy (cls.servername, server, sizeof (cls.servername) - 1);
|
strncpy (cls.servername, server, sizeof (cls.servername) - 1);
|
||||||
CL_BeginServerConnect ();
|
CL_BeginServerConnect ();
|
||||||
|
@ -1711,6 +1713,8 @@ Host_Init (void)
|
||||||
PR_Init ();
|
PR_Init ();
|
||||||
BI_Init ();
|
BI_Init ();
|
||||||
|
|
||||||
|
CL_Chat_Init ();
|
||||||
|
|
||||||
CL_Cmd_Init ();
|
CL_Cmd_Init ();
|
||||||
V_Init ();
|
V_Init ();
|
||||||
Game_Init ();
|
Game_Init ();
|
||||||
|
|
|
@ -62,6 +62,7 @@ static __attribute__ ((unused)) const char rcsid[] =
|
||||||
|
|
||||||
#include "bothdefs.h"
|
#include "bothdefs.h"
|
||||||
#include "cl_cam.h"
|
#include "cl_cam.h"
|
||||||
|
#include "cl_chat.h"
|
||||||
#include "cl_ents.h"
|
#include "cl_ents.h"
|
||||||
#include "cl_input.h"
|
#include "cl_input.h"
|
||||||
#include "cl_main.h"
|
#include "cl_main.h"
|
||||||
|
@ -1030,17 +1031,21 @@ CL_UpdateUserinfo (void)
|
||||||
("CL_ParseServerMessage: svc_updateuserinfo > MAX_SCOREBOARD");
|
("CL_ParseServerMessage: svc_updateuserinfo > MAX_SCOREBOARD");
|
||||||
|
|
||||||
player = &cl.players[slot];
|
player = &cl.players[slot];
|
||||||
if (player->userinfo)
|
|
||||||
Info_Destroy (player->userinfo);
|
|
||||||
uid = MSG_ReadLong (net_message);
|
uid = MSG_ReadLong (net_message);
|
||||||
info = MSG_ReadString (net_message);
|
info = MSG_ReadString (net_message);
|
||||||
if (*info) {
|
if (*info) {
|
||||||
// a totally empty userinfo string should not be possible
|
// a totally empty userinfo string should not be possible
|
||||||
player->userid = uid;
|
player->userid = uid;
|
||||||
|
if (player->userinfo)
|
||||||
|
Info_Destroy (player->userinfo);
|
||||||
player->userinfo = Info_ParseString (info, MAX_INFO_STRING, 0);
|
player->userinfo = Info_ParseString (info, MAX_INFO_STRING, 0);
|
||||||
CL_ProcessUserInfo (slot, player);
|
CL_ProcessUserInfo (slot, player);
|
||||||
|
CL_Chat_Check_Name (Info_ValueForKey (player->userinfo, "name"), slot);
|
||||||
} else {
|
} else {
|
||||||
// the server dropped the client
|
// the server dropped the client
|
||||||
|
CL_Chat_User_Disconnected (player->userid);
|
||||||
|
if (player->userinfo)
|
||||||
|
Info_Destroy (player->userinfo);
|
||||||
memset (player, 0, sizeof (*player));
|
memset (player, 0, sizeof (*player));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1232,6 +1237,8 @@ CL_ParseServerMessage (void)
|
||||||
i = MSG_ReadByte (net_message);
|
i = MSG_ReadByte (net_message);
|
||||||
s = MSG_ReadString (net_message);
|
s = MSG_ReadString (net_message);
|
||||||
if (i == PRINT_CHAT) {
|
if (i == PRINT_CHAT) {
|
||||||
|
if (!CL_Chat_Allow_Message (s))
|
||||||
|
break;
|
||||||
// TODO: cl_nofake 2 -- accept fake messages from teammates
|
// TODO: cl_nofake 2 -- accept fake messages from teammates
|
||||||
|
|
||||||
if (cl_nofake->int_val) {
|
if (cl_nofake->int_val) {
|
||||||
|
|
Loading…
Reference in a new issue