From 6efd4cef3cfcc44d6727cb0e54da26fbb74a7533 Mon Sep 17 00:00:00 2001 From: Tim Angus Date: Tue, 13 Oct 2009 17:17:27 +0000 Subject: * Merge ioq3-r1666 --- src/client/cl_main.c | 85 +++++++++++++++++----------------------------------- 1 file changed, 28 insertions(+), 57 deletions(-) (limited to 'src/client/cl_main.c') diff --git a/src/client/cl_main.c b/src/client/cl_main.c index 0aafa529..a8b59c27 100644 --- a/src/client/cl_main.c +++ b/src/client/cl_main.c @@ -191,7 +191,7 @@ void CL_UpdateVoipIgnore(const char *idstr, qboolean ignore) if ((id >= 0) && (id < MAX_CLIENTS)) { clc.voipIgnore[id] = ignore; CL_AddReliableCommand(va("voip %s %d", - ignore ? "ignore" : "unignore", id)); + ignore ? "ignore" : "unignore", id), qfalse); Com_Printf("VoIP: %s ignoring player #%d\n", ignore ? "Now" : "No longer", id); return; @@ -303,11 +303,11 @@ void CL_Voip_f( void ) } } else if (strcmp(cmd, "muteall") == 0) { Com_Printf("VoIP: muting incoming voice\n"); - CL_AddReliableCommand("voip muteall"); + CL_AddReliableCommand("voip muteall", qfalse); clc.voipMuteAll = qtrue; } else if (strcmp(cmd, "unmuteall") == 0) { Com_Printf("VoIP: unmuting incoming voice\n"); - CL_AddReliableCommand("voip unmuteall"); + CL_AddReliableCommand("voip unmuteall", qfalse); clc.voipMuteAll = qfalse; } else { Com_Printf("usage: voip [un]ignore \n" @@ -510,17 +510,25 @@ The given command will be transmitted to the server, and is gauranteed to not have future usercmd_t executed before it is executed ====================== */ -void CL_AddReliableCommand( const char *cmd ) { - int index; - +void CL_AddReliableCommand(const char *cmd, qboolean isDisconnectCmd) +{ + int unacknowledged = clc.reliableSequence - clc.reliableAcknowledge; + // if we would be losing an old command that hasn't been acknowledged, // we must drop the connection - if ( clc.reliableSequence - clc.reliableAcknowledge > MAX_RELIABLE_COMMANDS ) { - Com_Error( ERR_DROP, "Client command overflow" ); + // also leave one slot open for the disconnect command in this case. + + if ((isDisconnectCmd && unacknowledged > MAX_RELIABLE_COMMANDS) || + (!isDisconnectCmd && unacknowledged >= MAX_RELIABLE_COMMANDS)) + { + if(com_errorEntered) + return; + else + Com_Error(ERR_DROP, "Client command overflow"); } - clc.reliableSequence++; - index = clc.reliableSequence & ( MAX_RELIABLE_COMMANDS - 1 ); - Q_strncpyz( clc.reliableCommands[ index ], cmd, sizeof( clc.reliableCommands[ index ] ) ); + + Q_strncpyz(clc.reliableCommands[++clc.reliableSequence & (MAX_RELIABLE_COMMANDS - 1)], + cmd, sizeof(*clc.reliableCommands)); } /* @@ -1329,7 +1337,7 @@ void CL_Disconnect( qboolean showMainMenu ) { // send a disconnect message to the server // send it a few times in case one is dropped if ( cls.state >= CA_CONNECTED ) { - CL_AddReliableCommand( "disconnect" ); + CL_AddReliableCommand("disconnect", qtrue); CL_WritePacket(); CL_WritePacket(); CL_WritePacket(); @@ -1388,9 +1396,9 @@ void CL_ForwardCommandToServer( const char *string ) { } if ( Cmd_Argc() > 1 ) { - CL_AddReliableCommand( string ); + CL_AddReliableCommand(string, qfalse); } else { - CL_AddReliableCommand( cmd ); + CL_AddReliableCommand(cmd, qfalse); } } @@ -1457,45 +1465,10 @@ void CL_ForwardToServer_f( void ) { // don't forward the first argument if ( Cmd_Argc() > 1 ) { - CL_AddReliableCommand( Cmd_Args() ); - } -} - -/* -================== -CL_Setenv_f - -Mostly for controlling voodoo environment variables -================== -*/ -void CL_Setenv_f( void ) { - int argc = Cmd_Argc(); - - if ( argc > 2 ) { - char buffer[1024]; - int i; - - strcpy( buffer, Cmd_Argv(1) ); - strcat( buffer, "=" ); - - for ( i = 2; i < argc; i++ ) { - strcat( buffer, Cmd_Argv( i ) ); - strcat( buffer, " " ); - } - - putenv( buffer ); - } else if ( argc == 2 ) { - char *env = getenv( Cmd_Argv(1) ); - - if ( env ) { - Com_Printf( "%s=%s\n", Cmd_Argv(1), env ); - } else { - Com_Printf( "%s undefined\n", Cmd_Argv(1)); - } + CL_AddReliableCommand(Cmd_Args(), qfalse); } } - /* ================== CL_Disconnect_f @@ -1697,7 +1670,7 @@ void CL_SendPureChecksums( void ) { // if we are pure we need to send back a command with our referenced pk3 checksums Com_sprintf(cMsg, sizeof(cMsg), "cp %d %s", cl.serverId, FS_ReferencedPakPureChecksums()); - CL_AddReliableCommand( cMsg ); + CL_AddReliableCommand(cMsg, qfalse); } /* @@ -1706,7 +1679,7 @@ CL_ResetPureClientAtServer ================= */ void CL_ResetPureClientAtServer( void ) { - CL_AddReliableCommand( va("vdr") ); + CL_AddReliableCommand("vdr", qfalse); } /* @@ -1888,7 +1861,7 @@ void CL_DownloadsComplete( void ) { FS_Restart(clc.checksumFeed); // We possibly downloaded a pak, restart the file system to load it // inform the server so we get new gamestate info - CL_AddReliableCommand( "donedl" ); + CL_AddReliableCommand("donedl", qfalse); // by sending the donedl command we request a new gamestate // so we don't want to load stuff yet @@ -1958,7 +1931,7 @@ void CL_BeginDownload( const char *localName, const char *remoteName ) { // Stop any errant looping sounds that may be playing S_ClearLoopingSounds( qtrue ); - CL_AddReliableCommand( va("download %s", remoteName) ); + CL_AddReliableCommand( va("download %s", remoteName), qfalse ); } /* @@ -2809,7 +2782,7 @@ void CL_CheckUserinfo( void ) { if(cvar_modifiedFlags & CVAR_USERINFO) { cvar_modifiedFlags &= ~CVAR_USERINFO; - CL_AddReliableCommand( va("userinfo \"%s\"", Cvar_InfoString( CVAR_USERINFO ) ) ); + CL_AddReliableCommand(va("userinfo \"%s\"", Cvar_InfoString( CVAR_USERINFO ) ), qfalse); } } @@ -3455,7 +3428,6 @@ void CL_Init( void ) { Cmd_AddCommand ("globalservers", CL_GlobalServers_f); Cmd_AddCommand ("rcon", CL_Rcon_f); Cmd_SetCommandCompletionFunc( "rcon", CL_CompleteRcon ); - Cmd_AddCommand ("setenv", CL_Setenv_f ); Cmd_AddCommand ("ping", CL_Ping_f ); Cmd_AddCommand ("serverstatus", CL_ServerStatus_f ); Cmd_AddCommand ("showip", CL_ShowIP_f ); @@ -3522,7 +3494,6 @@ void CL_Shutdown( void ) { Cmd_RemoveCommand ("localservers"); Cmd_RemoveCommand ("globalservers"); Cmd_RemoveCommand ("rcon"); - Cmd_RemoveCommand ("setenv"); Cmd_RemoveCommand ("ping"); Cmd_RemoveCommand ("serverstatus"); Cmd_RemoveCommand ("showip"); -- cgit