/* * TV_Downstream_Msg * * NULL sends to all the message to all clients */ void TV_Downstream_Msg( client_t *client, relay_t *relay, client_t *who, qboolean chat, const char *format, ... ) { int i; char msg[1024]; va_list argptr; char *s, *p; va_start( argptr, format ); Q_vsnprintfz( msg, sizeof( msg ), format, argptr ); va_end( argptr ); // double quotes are bad p = msg; while( ( p = strchr( p, '\"' ) ) != NULL ) *p = '\''; if( chat ) s = va( "tvch \"%s\" \"%s\"", (who ? who->name : ""), msg ); else s = va( "pr \"%s\"", msg ); if( !client ) { // mirror at server console if( !relay ) // lobby Com_Printf( "%s", msg ); for( i = 0, client = tvs.clients; i < tv_maxclients->integer; i++, client++ ) { if( client->state < CS_SPAWNED ) continue; if( client->relay != relay ) continue; TV_Downstream_AddGameCommand( relay, client, s ); } } else { if( client->state == CS_SPAWNED ) TV_Downstream_AddGameCommand( client->relay, client, s ); } }
/* * TV_Module_GameCmd * * Sends the server command to clients. * if numClient is -1 the command will be sent to all connected clients */ static void TV_Module_GameCmd( relay_t *relay, int numClient, const char *cmd ) { int i; client_t *client; if( !relay ) { Com_Printf( "Error: TV_Module_GameCmd: Relay not set\n" ); return; } if( !cmd || !cmd[0] ) TV_Relay_Error( relay, "TV_Module_GameCmd: Missing command" ); if( numClient < -1 || numClient >= tv_maxclients->integer ) TV_Relay_Error( relay, "TV_Module_GameCmd: Invalid numClient" ); if( numClient == -1 ) { for( i = 0, client = tvs.clients; i < tv_maxclients->integer; i++, client++ ) { if( client->state < CS_SPAWNED ) continue; if( client->relay != relay ) continue; TV_Downstream_AddGameCommand( relay, client, cmd ); } } else { client = &tvs.clients[numClient]; if( client->state == CS_FREE || client->state == CS_ZOMBIE || client->relay != relay ) TV_Relay_Error( relay, "TV_Module_GameCmd: Invalid client" ); TV_Downstream_AddGameCommand( relay, client, cmd ); } }