From f1a51e13c659ac80ccc2e9bc453d7e671262d564 Mon Sep 17 00:00:00 2001 From: Pan7 Date: Fri, 18 Jul 2014 00:15:05 +0200 Subject: sayto cmd with player name completion --- src/server/sv_ccmds.c | 65 +++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 65 insertions(+) (limited to 'src/server') diff --git a/src/server/sv_ccmds.c b/src/server/sv_ccmds.c index 3ec3b8c7..1cc6cf3e 100644 --- a/src/server/sv_ccmds.c +++ b/src/server/sv_ccmds.c @@ -223,6 +223,71 @@ static void SV_MapRestart_f( void ) { } +/* +================== +SV_ConSayto_f +================== +*/ +static void SV_ConSayto_f(void) { + char *p; + char text[1024]; + client_t *cl; + char *rawname; + char name[MAX_NAME_LENGTH]; + char cleanName[MAX_NAME_LENGTH]; + client_t *saytocl; + int i; + + // make sure server is running + if ( !com_sv_running->integer ) { + Com_Printf( "Server is not running.\n" ); + return; + } + + if ( Cmd_Argc() < 3 ) { + Com_Printf ("Usage: sayto \n"); + return; + } + + rawname = Cmd_Argv(1); + + //allowing special characters in the console + //with hex strings for player names + Com_FieldStringToPlayerName( name, MAX_NAME_LENGTH, rawname ); + + saytocl = NULL; + for ( i=0, cl=svs.clients ; i < sv_maxclients->integer ; i++,cl++ ) { + if ( !cl->state ) { + continue; + } + Q_strncpyz( cleanName, cl->name, sizeof(cleanName) ); + Q_CleanStr( cleanName ); + + if ( !Q_stricmp( cleanName, name ) ) { + saytocl = cl; + break; + } + } + if( !saytocl ) + { + Com_Printf ("No such player name: %s.\n", name); + return; + } + + strcpy (text, "console_sayto: "); + p = Cmd_ArgsFrom(2); + + if ( *p == '"' ) { + p++; + p[strlen(p)-1] = 0; + } + + strcat(text, p); + + SV_SendServerCommand(saytocl, "chat \"%s\"", text); +} + + /* ================== SV_Heartbeat_f -- cgit From 975d4d97e4b9459c3d21b4dc3ecd807e9c330d9a Mon Sep 17 00:00:00 2001 From: Zack Middleton Date: Tue, 10 Dec 2013 21:14:13 -0600 Subject: Use Opus for VoIP Server/client VoIP protocol is handled by adding new cvars cl_voipProtocol and sv_voipProtocol, sv_voip and cl_voip are used to auto set/clear them. All users need to touch are cl/sv_voip as 0 or 1 just like before. Old Speex VoIP packets in demos are skipped. New VoIP packets are skipped in demos if sv_voipProtocol doesn't match cl_voipProtocol. Notable difference between usage of speex and opus codecs, when using Speex client would be sent 80ms at a time. Using Opus, 60ms is sent at a time. This was changed because the Opus codec supports encoding up to 60ms at a time. (Simpler to send only one codec frame in a packet.) --- src/server/server.h | 3 ++- src/server/sv_client.c | 22 +++++++++++++++------- src/server/sv_init.c | 3 ++- src/server/sv_main.c | 5 +++-- src/server/sv_snapshot.c | 2 +- 5 files changed, 23 insertions(+), 12 deletions(-) (limited to 'src/server') diff --git a/src/server/server.h b/src/server/server.h index 59b3ff8b..57d34b5b 100644 --- a/src/server/server.h +++ b/src/server/server.h @@ -45,7 +45,7 @@ typedef struct voipServerPacket_s int len; int sender; int flags; - byte data[1024]; + byte data[4000]; } voipServerPacket_t; #endif @@ -281,6 +281,7 @@ extern cvar_t *sv_banFile; #ifdef USE_VOIP extern cvar_t *sv_voip; +extern cvar_t *sv_voipProtocol; #endif diff --git a/src/server/sv_client.c b/src/server/sv_client.c index ba4392f7..dcf6311e 100644 --- a/src/server/sv_client.c +++ b/src/server/sv_client.c @@ -1200,8 +1200,8 @@ void SV_UserinfoChanged( client_t *cl ) { } #ifdef USE_VOIP - val = Info_ValueForKey(cl->userinfo, "cl_voip"); - cl->hasVoip = atoi(val); + val = Info_ValueForKey(cl->userinfo, "cl_voipProtocol"); + cl->hasVoip = !Q_stricmp( val, "opus" ); #endif // TTimo @@ -1536,7 +1536,7 @@ static qboolean SV_ShouldIgnoreVoipSender(const client_t *cl) } static -void SV_UserVoip(client_t *cl, msg_t *msg) +void SV_UserVoip(client_t *cl, msg_t *msg, qboolean ignoreData) { int sender, generation, sequence, frames, packetsize; uint8_t recips[(MAX_CLIENTS + 7) / 8]; @@ -1571,12 +1571,12 @@ void SV_UserVoip(client_t *cl, msg_t *msg) MSG_ReadData(msg, encoded, packetsize); - if (SV_ShouldIgnoreVoipSender(cl)) + if (ignoreData || SV_ShouldIgnoreVoipSender(cl)) return; // Blacklisted, disabled, etc. // !!! FIXME: see if we read past end of msg... - // !!! FIXME: reject if not speex narrowband codec. + // !!! FIXME: reject if not opus data. // !!! FIXME: decide if this is bogus data? // decide who needs this VoIP packet sent to them... @@ -1725,10 +1725,18 @@ void SV_ExecuteClientMessage( client_t *cl, msg_t *msg ) { } } while ( 1 ); + // skip legacy speex voip data + if ( c == clc_voipSpeex ) { +#ifdef USE_VOIP + SV_UserVoip( cl, msg, qtrue ); + c = MSG_ReadByte( msg ); +#endif + } + // read optional voip data - if ( c == clc_voip ) { + if ( c == clc_voipOpus ) { #ifdef USE_VOIP - SV_UserVoip( cl, msg ); + SV_UserVoip( cl, msg, qfalse ); c = MSG_ReadByte( msg ); #endif } diff --git a/src/server/sv_init.c b/src/server/sv_init.c index 30fd3936..997d58f6 100644 --- a/src/server/sv_init.c +++ b/src/server/sv_init.c @@ -646,8 +646,9 @@ void SV_Init (void) sv_serverid = Cvar_Get ("sv_serverid", "0", CVAR_SYSTEMINFO | CVAR_ROM ); sv_pure = Cvar_Get ("sv_pure", "1", CVAR_SYSTEMINFO ); #ifdef USE_VOIP - sv_voip = Cvar_Get("sv_voip", "1", CVAR_SYSTEMINFO | CVAR_LATCH); + sv_voip = Cvar_Get("sv_voip", "1", CVAR_LATCH); Cvar_CheckRange(sv_voip, 0, 1, qtrue); + sv_voipProtocol = Cvar_Get("sv_voipProtocol", sv_voip->integer ? "opus" : "", CVAR_SYSTEMINFO | CVAR_ROM ); #endif Cvar_Get ("sv_paks", "", CVAR_SYSTEMINFO | CVAR_ROM ); Cvar_Get ("sv_pakNames", "", CVAR_SYSTEMINFO | CVAR_ROM ); diff --git a/src/server/sv_main.c b/src/server/sv_main.c index 77d1a35d..0c4c7f46 100644 --- a/src/server/sv_main.c +++ b/src/server/sv_main.c @@ -25,6 +25,7 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA #ifdef USE_VOIP cvar_t *sv_voip; +cvar_t *sv_voipProtocol; #endif serverStatic_t svs; // persistant server info @@ -656,8 +657,8 @@ void SVC_Info( netadr_t from ) { Info_SetValueForKey( infostring, "pure", va("%i", sv_pure->integer ) ); #ifdef USE_VOIP - if (sv_voip->integer) { - Info_SetValueForKey( infostring, "voip", va("%i", sv_voip->integer ) ); + if (sv_voipProtocol->string && *sv_voipProtocol->string) { + Info_SetValueForKey( infostring, "voip", sv_voipProtocol->string ); } #endif diff --git a/src/server/sv_snapshot.c b/src/server/sv_snapshot.c index 71c4b86c..58136388 100644 --- a/src/server/sv_snapshot.c +++ b/src/server/sv_snapshot.c @@ -548,7 +548,7 @@ static void SV_WriteVoipToClient(client_t *cl, msg_t *msg) if (totalbytes > (msg->maxsize - msg->cursize) / 2) break; - MSG_WriteByte(msg, svc_voip); + MSG_WriteByte(msg, svc_voipOpus); MSG_WriteShort(msg, packet->sender); MSG_WriteByte(msg, (byte) packet->generation); MSG_WriteLong(msg, packet->sequence); -- cgit From 87abdd914988724e164ffb16380ad26be8420b84 Mon Sep 17 00:00:00 2001 From: Tim Angus Date: Thu, 7 Apr 2016 11:58:19 +0100 Subject: Make it compile --- src/server/sv_ccmds.c | 65 --------------------------------------------------- 1 file changed, 65 deletions(-) (limited to 'src/server') diff --git a/src/server/sv_ccmds.c b/src/server/sv_ccmds.c index 1cc6cf3e..3ec3b8c7 100644 --- a/src/server/sv_ccmds.c +++ b/src/server/sv_ccmds.c @@ -223,71 +223,6 @@ static void SV_MapRestart_f( void ) { } -/* -================== -SV_ConSayto_f -================== -*/ -static void SV_ConSayto_f(void) { - char *p; - char text[1024]; - client_t *cl; - char *rawname; - char name[MAX_NAME_LENGTH]; - char cleanName[MAX_NAME_LENGTH]; - client_t *saytocl; - int i; - - // make sure server is running - if ( !com_sv_running->integer ) { - Com_Printf( "Server is not running.\n" ); - return; - } - - if ( Cmd_Argc() < 3 ) { - Com_Printf ("Usage: sayto \n"); - return; - } - - rawname = Cmd_Argv(1); - - //allowing special characters in the console - //with hex strings for player names - Com_FieldStringToPlayerName( name, MAX_NAME_LENGTH, rawname ); - - saytocl = NULL; - for ( i=0, cl=svs.clients ; i < sv_maxclients->integer ; i++,cl++ ) { - if ( !cl->state ) { - continue; - } - Q_strncpyz( cleanName, cl->name, sizeof(cleanName) ); - Q_CleanStr( cleanName ); - - if ( !Q_stricmp( cleanName, name ) ) { - saytocl = cl; - break; - } - } - if( !saytocl ) - { - Com_Printf ("No such player name: %s.\n", name); - return; - } - - strcpy (text, "console_sayto: "); - p = Cmd_ArgsFrom(2); - - if ( *p == '"' ) { - p++; - p[strlen(p)-1] = 0; - } - - strcat(text, p); - - SV_SendServerCommand(saytocl, "chat \"%s\"", text); -} - - /* ================== SV_Heartbeat_f -- cgit