summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrey Nazarov <skuller@skuller.net>2008-01-04 22:45:32 +0000
committerAndrey Nazarov <skuller@skuller.net>2008-01-04 22:45:32 +0000
commitcfed1adf2730a07f31ccb7644f274ead21c31879 (patch)
treea24638d36c785264178203801f6945fec2ef5a9c
parent0f73c3d00f54ed960cf01d0cfe30734cda26586c (diff)
Updated revision to 177.
Updated minor MVD protocol version to 2010. Do not wrap bprintf messages into mvd_multicast, use mvd_print instead. Locked `sv_mvd_wait' variable until things are sorted out.
-rwxr-xr-xconfigure2
-rw-r--r--source/cmd.c57
-rw-r--r--source/mvd_client.c4
-rw-r--r--source/mvd_game.c41
-rw-r--r--source/mvd_local.h2
-rw-r--r--source/mvd_parse.c16
-rw-r--r--source/protocol.h6
-rw-r--r--source/sv_game.c7
-rw-r--r--source/sv_local.h1
-rw-r--r--source/sv_mvd.c15
10 files changed, 79 insertions, 72 deletions
diff --git a/configure b/configure
index 02372a0..bf176db 100755
--- a/configure
+++ b/configure
@@ -61,7 +61,7 @@ histfile=".conhistory"
democache=".democache"
screenshots="screenshots"
scoreshots="scoreshots"
-revision="176"
+revision="177"
tmpc="/tmp/q2pro-${RANDOM}.c"
tmpo="/tmp/q2pro-${RANDOM}.o"
diff --git a/source/cmd.c b/source/cmd.c
index 43fb9c8..e4526d3 100644
--- a/source/cmd.c
+++ b/source/cmd.c
@@ -491,14 +491,17 @@ static char *cmd_argv[MAX_STRING_TOKENS];
static char *cmd_null_string = "";
/* complete command string, quotes preserved */
-static char cmd_args[MAX_STRING_CHARS];
+static char cmd_string[MAX_STRING_CHARS];
+static int cmd_string_len;
-/* offsets of individual tokens in cmd_args */
+/* offsets of individual tokens in cmd_string */
static int cmd_offsets[MAX_STRING_TOKENS];
/* sequence of NULL-terminated tokens, each cmd_argv[] points here */
static char cmd_data[MAX_STRING_CHARS];
+static char cmd_args[MAX_STRING_CHARS];
+
int cmd_optind;
char *cmd_optarg;
char *cmd_optopt;
@@ -508,7 +511,7 @@ int Cmd_ArgOffset( int arg ) {
return 0;
}
if( arg >= cmd_argc ) {
- return strlen( cmd_args );
+ return cmd_string_len;
}
return cmd_offsets[arg];
}
@@ -550,7 +553,7 @@ char *Cmd_Argv( int arg ) {
Cmd_ArgvBuffer
============
*/
-void Cmd_ArgvBuffer( int arg, char *buffer, int bufferSize ) {
+void Cmd_ArgvBuffer( int arg, char *buffer, int size ) {
char *s;
if( arg < 0 || arg >= cmd_argc ) {
@@ -559,7 +562,7 @@ void Cmd_ArgvBuffer( int arg, char *buffer, int bufferSize ) {
s = cmd_argv[arg];
}
- Q_strncpyz( buffer, s, bufferSize );
+ Q_strncpyz( buffer, s, size );
}
@@ -571,43 +574,40 @@ Returns a single string containing argv(1) to argv(argc()-1)
============
*/
char *Cmd_Args( void ) {
- static char args[MAX_STRING_CHARS];
int i;
if( cmd_argc < 2 ) {
return cmd_null_string;
}
- args[0] = 0;
+ cmd_args[0] = 0;
for( i = 1; i < cmd_argc - 1; i++ ) {
- strcat( args, cmd_argv[i] );
- strcat( args, " " );
+ strcat( cmd_args, cmd_argv[i] );
+ strcat( cmd_args, " " );
}
- strcat( args, cmd_argv[i] );
+ strcat( cmd_args, cmd_argv[i] );
- return args;
+ return cmd_args;
}
char *Cmd_RawArgs( void ) {
if( cmd_argc < 2 ) {
return cmd_null_string;
}
- return cmd_args + cmd_offsets[1];
+ return cmd_string + cmd_offsets[1];
}
char *Cmd_RawString( void ) {
- return cmd_args;
+ return cmd_string;
}
-
-
/*
============
Cmd_ArgsBuffer
============
*/
-void Cmd_ArgsBuffer( char *buffer, int bufferSize ) {
- Q_strncpyz( buffer, Cmd_Args(), bufferSize );
+void Cmd_ArgsBuffer( char *buffer, int size ) {
+ Q_strncpyz( buffer, Cmd_Args(), size );
}
/*
@@ -618,21 +618,20 @@ Returns a single string containing argv(1) to argv(from-1)
============
*/
char *Cmd_ArgsFrom( int from ) {
- static char args[MAX_STRING_CHARS];
int i;
if( from < 0 || from >= cmd_argc ) {
return cmd_null_string;
}
- args[0] = 0;
+ cmd_args[0] = 0;
for( i = from; i < cmd_argc - 1; i++ ) {
- strcat( args, cmd_argv[i] );
- strcat( args, " " );
+ strcat( cmd_args, cmd_argv[i] );
+ strcat( cmd_args, " " );
}
- strcat( args, cmd_argv[i] );
+ strcat( cmd_args, cmd_argv[i] );
- return args;
+ return cmd_args;
}
char *Cmd_RawArgsFrom( int from ) {
@@ -644,7 +643,7 @@ char *Cmd_RawArgsFrom( int from ) {
offset = cmd_offsets[from];
- return cmd_args + offset;
+ return cmd_string + offset;
}
void Cmd_Shift( void ) {
@@ -655,7 +654,7 @@ void Cmd_Shift( void ) {
}
if( cmd_argc == 1 ) {
- cmd_args[0] = 0;
+ cmd_string[0] = 0;
return;
}
@@ -665,7 +664,7 @@ void Cmd_Shift( void ) {
cmd_argv[i] = cmd_argv[ i + 1 ];
}
- memmove( cmd_args, cmd_args + cmd_offsets[1],
+ memmove( cmd_string, cmd_string + cmd_offsets[1],
MAX_STRING_CHARS - cmd_offsets[1] );
}
@@ -962,7 +961,7 @@ void Cmd_TokenizeString( const char *text, qboolean macroExpand ) {
}
cmd_argc = 0;
- cmd_args[0] = 0;
+ cmd_string[0] = 0;
cmd_optind = 1;
cmd_optarg = cmd_optopt = cmd_null_string;
@@ -978,10 +977,10 @@ void Cmd_TokenizeString( const char *text, qboolean macroExpand ) {
}
}
- Q_strncpyz( cmd_args, text, sizeof( cmd_args ) );
+ cmd_string_len = Q_strncpyz( cmd_string, text, sizeof( cmd_string ) );
dest = cmd_data;
- start = data = cmd_args;
+ start = data = cmd_string;
while( cmd_argc < MAX_STRING_TOKENS ) {
// skip whitespace up to a /n
while( *data <= 32 ) {
diff --git a/source/mvd_client.c b/source/mvd_client.c
index a47f6a8..4d6cfcd 100644
--- a/source/mvd_client.c
+++ b/source/mvd_client.c
@@ -223,7 +223,7 @@ static void MVD_EmitGamestate( mvd_t *mvd ) {
// send the serverdata
MSG_WriteByte( mvd_serverdata );
MSG_WriteLong( PROTOCOL_VERSION_MVD );
- MSG_WriteShort( PROTOCOL_VERSION_MVD_MINOR );
+ MSG_WriteShort( PROTOCOL_VERSION_MVD_CURRENT );
MSG_WriteLong( mvd->servercount );
MSG_WriteString( mvd->gamedir );
MSG_WriteShort( mvd->clientNum );
@@ -933,7 +933,7 @@ MVD_Connect_f
void MVD_Connect_f( void ) {
static const cmd_option_t options[] = {
{ "h", "help", "display this message" },
- { "e:number", "encoding", "assume encoding identified by <number>" },
+ { "e:string", "encoding", "specify default encoding as <string>" },
{ "i:number", "id", "specify remote stream ID as <number>" },
{ "n:string", "name", "specify channel name as <string>" },
{ "r:string", "referer", "specify referer as <string> in HTTP request" },
diff --git a/source/mvd_game.c b/source/mvd_game.c
index 4fc07a3..2a6bff1 100644
--- a/source/mvd_game.c
+++ b/source/mvd_game.c
@@ -381,7 +381,7 @@ SPECTATOR COMMANDS
==============================================================================
*/
-static void MVD_BroadcastPrintf( mvd_t *mvd, int level, const char *fmt, ... ) {
+void MVD_BroadcastPrintf( mvd_t *mvd, int level, int mask, const char *fmt, ... ) {
va_list argptr;
char text[MAXPRINTMSG];
int len;
@@ -404,7 +404,7 @@ static void MVD_BroadcastPrintf( mvd_t *mvd, int level, const char *fmt, ... ) {
if( level < cl->messagelevel ) {
continue;
}
- if( level == PRINT_CHAT && ( other->uf & UF_NOMVDCHAT ) ) {
+ if( level == PRINT_CHAT && ( other->uf & mask ) ) {
continue;
}
SV_ClientAddMessage( cl, MSG_RELIABLE );
@@ -451,7 +451,7 @@ void MVD_TrySwitchChannel( udpClient_t *client, mvd_t *mvd ) {
"[MVD] You may not switch channels too soon.\n" );
return;
}
- MVD_BroadcastPrintf( client->mvd, PRINT_MEDIUM,
+ MVD_BroadcastPrintf( client->mvd, PRINT_MEDIUM, 0,
"[MVD] %s left the channel.\n", client->cl->name );
}
@@ -484,10 +484,8 @@ static void MVD_Admin_f( udpClient_t *client ) {
static void MVD_Say_f( udpClient_t *client ) {
mvd_t *mvd = client->mvd;
- udpClient_t *other;
- client_t *cl;
- char buffer[128];
- int i, len;
+ char *text;
+ int i;
if( mvd_flood_mute->integer && !client->admin ) {
SV_ClientPrintf( client->cl, PRINT_HIGH,
@@ -521,28 +519,11 @@ static void MVD_Say_f( udpClient_t *client ) {
client->floodSamples[client->floodHead & FLOOD_MASK] = sv.time;
client->floodHead++;
- len = Com_sprintf( buffer, sizeof( buffer ), "{%s}: %s\n",
- client->cl->name, Cmd_Args() );
+ text = Cmd_Args();
+ text[128] = 0; // don't let it be too long
- MSG_WriteByte( svc_print );
- MSG_WriteByte( PRINT_CHAT );
- MSG_WriteData( buffer, len + 1 );
-
- LIST_FOR_EACH( udpClient_t, other, &mvd->udpClients, entry ) {
- cl = other->cl;
- if( cl->state < cs_spawned ) {
- continue;
- }
- if( PRINT_CHAT < cl->messagelevel ) {
- continue;
- }
- if( ( other->uf & UF_NOMVDCHAT ) && !client->admin ) {
- continue;
- }
- SV_ClientAddMessage( cl, MSG_RELIABLE );
- }
-
- SZ_Clear( &msg_write );
+ MVD_BroadcastPrintf( mvd, PRINT_CHAT, client->admin ? 0 : UF_NOMVDCHAT,
+ "{%s}: %s\n", client->cl->name, text );
}
static void MVD_Observe_f( udpClient_t *client ) {
@@ -855,7 +836,7 @@ static void MVD_GameClientBegin( edict_t *ent ) {
memset( &client->ps, 0, sizeof( client->ps ) );
if( !client->begin_time ) {
- MVD_BroadcastPrintf( mvd, PRINT_MEDIUM,
+ MVD_BroadcastPrintf( mvd, PRINT_MEDIUM, 0,
"[MVD] %s entered the channel\n", client->cl->name );
}
client->begin_time = svs.realtime;
@@ -894,7 +875,7 @@ static void MVD_GameClientDisconnect( edict_t *ent ) {
client_t *cl = client->cl;
if( client->begin_time ) {
- MVD_BroadcastPrintf( client->mvd, PRINT_MEDIUM,
+ MVD_BroadcastPrintf( client->mvd, PRINT_MEDIUM, 0,
"[MVD] %s disconnected\n", cl->name );
client->begin_time = 0;
}
diff --git a/source/mvd_local.h b/source/mvd_local.h
index becdd09..766186f 100644
--- a/source/mvd_local.h
+++ b/source/mvd_local.h
@@ -213,4 +213,6 @@ extern game_export_t mvd_ge;
void MVD_UpdateClient( udpClient_t *client );
void MVD_SwitchChannel( udpClient_t *client, mvd_t *mvd );
void MVD_RemoveClient( client_t *client );
+void MVD_BroadcastPrintf( mvd_t *mvd, int level,
+ int mask, const char *fmt, ... ) q_printf( 4, 5 );
diff --git a/source/mvd_parse.c b/source/mvd_parse.c
index 819211e..72449fb 100644
--- a/source/mvd_parse.c
+++ b/source/mvd_parse.c
@@ -692,6 +692,13 @@ static void MVD_ParseConfigstring( mvd_t *mvd ) {
SZ_Clear( &msg_write );
}
+static void MVD_ParsePrint( mvd_t *mvd ) {
+ int level = MSG_ReadByte();
+ char *string = MSG_ReadString();
+
+ MVD_BroadcastPrintf( mvd, level, UF_NOGAMECHAT, "%s", string );
+}
+
/*
Fix origin and angles on each player entity by
extracting data from player state.
@@ -913,9 +920,9 @@ static void MVD_ParseServerData( mvd_t *mvd ) {
// parse minor protocol version
protocol = MSG_ReadShort();
- if( protocol != PROTOCOL_VERSION_MVD_MINOR ) {
- MVD_Destroyf( mvd, "MVD protocol version mismatch: %d instead of %d",
- protocol, PROTOCOL_VERSION_MVD_MINOR );
+ if( !MVD_SUPPORTED( protocol ) ) {
+ MVD_Destroyf( mvd, "Unsupported MVD protocol version: %d.\n"
+ "Current version is %d.\n", protocol, PROTOCOL_VERSION_MVD_CURRENT );
}
mvd->servercount = MSG_ReadLong();
@@ -1138,6 +1145,9 @@ static qboolean MVD_ParseMessage( mvd_t *mvd, fifo_t *fifo ) {
case mvd_sound:
MVD_ParseSound( mvd, extrabits );
break;
+ case mvd_print:
+ MVD_ParsePrint( mvd );
+ break;
default:
MVD_Destroyf( mvd, "Illegible command at %d: %d",
msg_read.readcount - 1, cmd );
diff --git a/source/protocol.h b/source/protocol.h
index ed9fa8e..6cc6613 100644
--- a/source/protocol.h
+++ b/source/protocol.h
@@ -35,7 +35,8 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#define PROTOCOL_VERSION_R1Q2_CURRENT 1904 // b7387
#define PROTOCOL_VERSION_Q2PRO_MINIMUM 1011 // r161
#define PROTOCOL_VERSION_Q2PRO_CURRENT 1011 // r161
-#define PROTOCOL_VERSION_MVD_MINOR 2009 // r168
+#define PROTOCOL_VERSION_MVD_MINIMUM 2009 // r168
+#define PROTOCOL_VERSION_MVD_CURRENT 2010 // r177
#define R1Q2_SUPPORTED( x ) ( (x) >= PROTOCOL_VERSION_R1Q2_MINIMUM && \
(x) <= PROTOCOL_VERSION_R1Q2_CURRENT )
@@ -43,6 +44,9 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#define Q2PRO_SUPPORTED( x ) ( (x) >= PROTOCOL_VERSION_Q2PRO_MINIMUM && \
(x) <= PROTOCOL_VERSION_Q2PRO_CURRENT )
+#define MVD_SUPPORTED( x ) ( (x) >= PROTOCOL_VERSION_MVD_MINIMUM && \
+ (x) <= PROTOCOL_VERSION_MVD_CURRENT )
+
//=========================================
#define PORT_MASTER 27900
diff --git a/source/sv_game.c b/source/sv_game.c
index 55c3a45..4cbad96 100644
--- a/source/sv_game.c
+++ b/source/sv_game.c
@@ -162,6 +162,10 @@ static void PF_bprintf( int level, const char *fmt, ... ) {
length = Q_vsnprintf( string, sizeof( string ), fmt, argptr );
va_end( argptr );
+ if( sv_mvd_enable->integer ) {
+ SV_MvdBroadcastPrint( level, string );
+ }
+
MSG_WriteByte( svc_print );
MSG_WriteByte( level );
MSG_WriteData( string, length + 1 );
@@ -181,9 +185,6 @@ static void PF_bprintf( int level, const char *fmt, ... ) {
SV_ClientAddMessage( client, MSG_RELIABLE );
}
}
- if( sv_mvd_enable->integer ) {
- SV_MvdMulticast( &sv.mvd.message, -1, mvd_multicast_all_r );
- }
SZ_Clear( &msg_write );
}
diff --git a/source/sv_local.h b/source/sv_local.h
index bc50b1f..339405b 100644
--- a/source/sv_local.h
+++ b/source/sv_local.h
@@ -485,6 +485,7 @@ void SV_MvdEndFrame( void );
void SV_MvdUnicast( sizebuf_t *buf, int clientNum, mvd_ops_t op );
void SV_MvdMulticast( sizebuf_t *buf, int leafnum, mvd_ops_t op );
void SV_MvdConfigstring( int index, const char *string );
+void SV_MvdBroadcastPrint( int level, const char *string );
void SV_MvdRecStop( void );
qboolean SV_MvdPlayerIsActive( edict_t *ent );
void SV_MvdClientNew( tcpClient_t *client );
diff --git a/source/sv_mvd.c b/source/sv_mvd.c
index 0a04971..df43b12 100644
--- a/source/sv_mvd.c
+++ b/source/sv_mvd.c
@@ -383,7 +383,7 @@ qboolean SV_MvdCreateDummy( void ) {
Com_sprintf( userinfo, sizeof( userinfo ),
"\\name\\[MVDSPEC]\\skin\\male/grunt\\mvdspec\\%d\\ip\\loopback",
- PROTOCOL_VERSION_MVD_MINOR );
+ PROTOCOL_VERSION_MVD_CURRENT );
svs.mvd.dummy = newcl;
@@ -607,7 +607,7 @@ static void SV_MvdEmitGamestate( void ) {
// send the serverdata
MSG_WriteByte( mvd_serverdata );
MSG_WriteLong( PROTOCOL_VERSION_MVD );
- MSG_WriteShort( PROTOCOL_VERSION_MVD_MINOR );
+ MSG_WriteShort( PROTOCOL_VERSION_MVD_CURRENT );
MSG_WriteLong( sv.spawncount );
MSG_WriteString( fs_game->string );
MSG_WriteShort( svs.mvd.dummy->number );
@@ -797,6 +797,15 @@ void SV_MvdConfigstring( int index, const char *string ) {
SZ_WriteString( &sv.mvd.message, string );
}
+void SV_MvdBroadcastPrint( int level, const char *string ) {
+ if( sv.mvd.paused >= PAUSED_FRAMES ) {
+ return;
+ }
+ SZ_WriteByte( &sv.mvd.message, mvd_print );
+ SZ_WriteByte( &sv.mvd.message, level );
+ SZ_WriteString( &sv.mvd.message, string );
+}
+
/*
==============
SV_MvdRecStop
@@ -932,7 +941,7 @@ static const cmdreg_t c_svmvd[] = {
void SV_MvdRegister( void ) {
sv_mvd_enable = Cvar_Get( "sv_mvd_enable", "0", CVAR_LATCH );
sv_mvd_auth = Cvar_Get( "sv_mvd_auth", "", CVAR_PRIVATE );
- sv_mvd_wait = Cvar_Get( "sv_mvd_wait", "0", 0 );
+ sv_mvd_wait = Cvar_Get( "sv_mvd_wait", "0", CVAR_ROM ); // TODO
sv_mvd_max_size = Cvar_Get( "sv_mvd_max_size", "0", 0 );
sv_mvd_max_duration = Cvar_Get( "sv_mvd_max_duration", "0", 0 );
sv_mvd_noblend = Cvar_Get( "sv_mvd_noblend", "0", CVAR_LATCH );