diff options
Diffstat (limited to 'src/server/sv_snapshot.c')
-rw-r--r-- | src/server/sv_snapshot.c | 55 |
1 files changed, 51 insertions, 4 deletions
diff --git a/src/server/sv_snapshot.c b/src/server/sv_snapshot.c index ddd87cc6..a16b6b2c 100644 --- a/src/server/sv_snapshot.c +++ b/src/server/sv_snapshot.c @@ -522,6 +522,53 @@ static void SV_BuildClientSnapshot( client_t *client ) { } } +#ifdef USE_VOIP +/* +================== +SV_WriteVoipToClient + +Check to see if there is any VoIP queued for a client, and send if there is. +================== +*/ +static void SV_WriteVoipToClient(client_t *cl, msg_t *msg) +{ + int totalbytes = 0; + int i; + voipServerPacket_t *packet; + + if(cl->queuedVoipPackets) + { + // Write as many VoIP packets as we reasonably can... + for(i = 0; i < cl->queuedVoipPackets; i++) + { + packet = cl->voipPacket[(i + cl->queuedVoipIndex) % ARRAY_LEN(cl->voipPacket)]; + + if(!*cl->downloadName) + { + totalbytes += packet->len; + if (totalbytes > (msg->maxsize - msg->cursize) / 2) + break; + + MSG_WriteByte(msg, svc_voip); + MSG_WriteShort(msg, packet->sender); + MSG_WriteByte(msg, (byte) packet->generation); + MSG_WriteLong(msg, packet->sequence); + MSG_WriteByte(msg, packet->frames); + MSG_WriteShort(msg, packet->len); + MSG_WriteBits(msg, packet->flags, VOIP_FLAGCNT); + MSG_WriteData(msg, packet->data, packet->len); + } + + Z_Free(packet); + } + + cl->queuedVoipPackets -= i; + cl->queuedVoipIndex += i; + cl->queuedVoipIndex %= ARRAY_LEN(cl->voipPacket); + } +} +#endif + /* ======================= SV_SendMessageToClient @@ -605,11 +652,11 @@ void SV_SendClientMessages(void) if(*c->downloadName) continue; // Client is downloading, don't send snapshots - if(c->netchan.unsentFragments || c->netchan_start_queue) - { - c->rateDelayed = qtrue; + if(c->netchan.unsentFragments || c->netchan_start_queue) + { + c->rateDelayed = qtrue; continue; // Drop this snapshot if the packet queue is still full or delta compression will break - } + } if(!(c->netchan.remoteAddress.type == NA_LOOPBACK || (sv_lanForceRate->integer && Sys_IsLANAddress(c->netchan.remoteAddress)))) |