engine/EngineServerUser.c
/*	Returns false if the client should be killed
*/
Returns false if the client should be killed
Returns false if the client should be killed
bool Server_ReadClientMessage(void)
{
	int		ret, ncmd;
	char	*s;
	do
	{
nextmsg:
		ret = NET_GetMessage (host_client->netconnection);
		if(ret == -1)
		{
			Sys_Printf ("SV_ReadClientMessage: NET_GetMessage failed\n");
			return false;
		}
		else if(!ret)
			return true;
		MSG_BeginReading ();
		for(;;)
		{
			if(!host_client->active)
				return false;	
			else if(msg_badread)
			{
				Sys_Printf ("SV_ReadClientMessage: badread\n");
				return false;
			}
			ncmd = MSG_ReadChar();
			switch(ncmd)
			{
			case -1:
				goto nextmsg;		
			default:
				Sys_Printf ("SV_ReadClientMessage: unknown command char\n");
				return false;
			case clc_nop:
				break;
			case clc_stringcmd:
				s = MSG_ReadString ();
				if (host_client->privileged)
					ret = 2;
				else
					ret = 0;
				if (Q_strncasecmp(s, "status", 6) == 0)
					ret = 1;
				else if (Q_strncasecmp(s, "god", 3) == 0)
					ret = 1;
				else if (Q_strncasecmp(s, "notarget", 8) == 0)
					ret = 1;
				else if (Q_strncasecmp(s, "fly", 3) == 0)
					ret = 1;
				else if (Q_strncasecmp(s, "name", 4) == 0)
					ret = 1;
				else if (Q_strncasecmp(s, "noclip", 6) == 0)
					ret = 1;
				else if (Q_strncasecmp(s, "say", 3) == 0)
					ret = 1;
				else if (Q_strncasecmp(s, "say_team", 8) == 0)
					ret = 1;
				else if (Q_strncasecmp(s, "tell", 4) == 0)
					ret = 1;
				else if (Q_strncasecmp(s, "color", 5) == 0)
					ret = 1;
				else if (Q_strncasecmp(s, "kill", 4) == 0)
					ret = 1;
				else if (Q_strncasecmp(s, "pause", 5) == 0)
					ret = 1;
				else if (Q_strncasecmp(s, "spawn", 5) == 0)
					ret = 1;
				else if (Q_strncasecmp(s, "begin", 5) == 0)
					ret = 1;
				else if (Q_strncasecmp(s, "prespawn", 8) == 0)
					ret = 1;
				else if (Q_strncasecmp(s, "kick", 4) == 0)
					ret = 1;
				else if (Q_strncasecmp(s, "ping", 4) == 0)
					ret = 1;
				else if (Q_strncasecmp(s, "give", 4) == 0)
					ret = 1;
				else if (Q_strncasecmp(s, "ban", 3) == 0)
					ret = 1;
				if (ret == 2)
					Cbuf_InsertText (s);
				else if (ret == 1)
					Cmd_ExecuteString (s, src_client);
				else
					Con_DPrintf("%s tried to %s\n", host_client->name, s);
				break;
			case clc_disconnect:
				return false;
			case clc_move:
				SV_ReadClientMove (&host_client->cmd);
				break;
			}
		}
	} while (ret == 1);
}
bool Server_ReadClientMessage ( void ) { int ret , ncmd ; char * s ; do { nextmsg : ret = NET_GetMessage ( host_client -> netconnection ) ; if ( ret == -1 ) { Sys_Printf ( " \n " ) ; return false ; } else if ( ! ret ) return true ; MSG_BeginReading ( ) ; for ( ; ; ) { if ( ! host_client -> active ) return false ; else if ( msg_badread ) { Sys_Printf ( " \n " ) ; return false ; } ncmd = MSG_ReadChar ( ) ; switch ( ncmd ) { case -1 : goto nextmsg ; default : Sys_Printf ( " \n " ) ; return false ; case clc_nop : break ; case clc_stringcmd : s = MSG_ReadString ( ) ; if ( host_client -> privileged ) ret = 2 ; else ret = 0 ; if ( Q_strncasecmp ( s , " " , 6 ) == 0 ) ret = 1 ; else if ( Q_strncasecmp ( s , " " , 3 ) == 0 ) ret = 1 ; else if ( Q_strncasecmp ( s , " " , 8 ) == 0 ) ret = 1 ; else if ( Q_strncasecmp ( s , " " , 3 ) == 0 ) ret = 1 ; else if ( Q_strncasecmp ( s , " " , 4 ) == 0 ) ret = 1 ; else if ( Q_strncasecmp ( s , " " , 6 ) == 0 ) ret = 1 ; else if ( Q_strncasecmp ( s , " " , 3 ) == 0 ) ret = 1 ; else if ( Q_strncasecmp ( s , " " , 8 ) == 0 ) ret = 1 ; else if ( Q_strncasecmp ( s , " " , 4 ) == 0 ) ret = 1 ; else if ( Q_strncasecmp ( s , " " , 5 ) == 0 ) ret = 1 ; else if ( Q_strncasecmp ( s , " " , 4 ) == 0 ) ret = 1 ; else if ( Q_strncasecmp ( s , " " , 5 ) == 0 ) ret = 1 ; else if ( Q_strncasecmp ( s , " " , 5 ) == 0 ) ret = 1 ; else if ( Q_strncasecmp ( s , " " , 5 ) == 0 ) ret = 1 ; else if ( Q_strncasecmp ( s , " " , 8 ) == 0 ) ret = 1 ; else if ( Q_strncasecmp ( s , " " , 4 ) == 0 ) ret = 1 ; else if ( Q_strncasecmp ( s , " " , 4 ) == 0 ) ret = 1 ; else if ( Q_strncasecmp ( s , " " , 4 ) == 0 ) ret = 1 ; else if ( Q_strncasecmp ( s , " " , 3 ) == 0 ) ret = 1 ; if ( ret == 2 ) Cbuf_InsertText ( s ) ; else if ( ret == 1 ) Cmd_ExecuteString ( s , src_client ) ; else Con_DPrintf ( " \n " , host_client -> name , s ) ; break ; case clc_disconnect : return false ; case clc_move : SV_ReadClientMove ( & host_client -> cmd ) ; break ; } } } while ( ret == 1 ) ; }
Returns false if the client should be killed
Returns false if the client should be killed
// a command caused an error // end of message