From 8c6ad4c73c816dbe412e6fac0ad1c0d2837492cc Mon Sep 17 00:00:00 2001 From: Paweł Redman Date: Sat, 4 Apr 2015 16:20:17 +0200 Subject: Let spectators see damage blobs of the spectated player. --- src/game/g_active.c | 37 +++++++++++++++++++++++++++++++++++-- 1 file changed, 35 insertions(+), 2 deletions(-) diff --git a/src/game/g_active.c b/src/game/g_active.c index 2eede6b..7148af0 100644 --- a/src/game/g_active.c +++ b/src/game/g_active.c @@ -2211,6 +2211,39 @@ void ClientThink_real( gentity_t *ent ) } } +/* +================== +G_SendPublicServerCommand + +Send a server command to a player and everyone following them. +================== +*/ +void G_SendPublicServerCommand( int clientNum, const char *cmd ) +{ + int i; + gclient_t *client; + + for( i = 0; i < level.maxclients ; i++ ) + { + client = level.clients + i; + + if( client->pers.connected != CON_CONNECTED ) + continue; + + if( client->ps.clientNum == clientNum ) + goto send; + + if( client->sess.spectatorState == SPECTATOR_NOT ) + continue; + + if( client->sess.spectatorClient != clientNum ) + continue; + + send: + trap_SendServerCommand( client->ps.clientNum, cmd ); + } +} + /* ================== ClientThink @@ -2261,7 +2294,7 @@ void G_RunClient( gentity_t *ent ) if( p - buffer + len + 1 > sizeof( buffer ) ) { - trap_SendServerCommand( ent - g_entities, buffer ); + G_SendPublicServerCommand( ent - g_entities, buffer ); strcpy( buffer, "dblob" ); p = buffer + 5; } @@ -2271,7 +2304,7 @@ void G_RunClient( gentity_t *ent ) } if( p > buffer + 6 ) - trap_SendServerCommand( ent - g_entities, buffer ); + G_SendPublicServerCommand( ent - g_entities, buffer ); ent->client->bufferedBlobCount = 0; } -- cgit