void ClientReliableWrite_Entity(client_t *cl, int c) { if (cl->num_backbuf) { MSG_WriteEntity(&cl->backbuf, c); ClientReliable_FinishWrite(cl); } else MSG_WriteEntity(&cl->netchan.message, c); }
/* ============= SV_EmitPacketEntities Writes a delta update of an entityState_t list to the message. ============= */ static void SV_EmitPacketEntities( clientSnapshot_t *from, clientSnapshot_t *to, msg_t *msg ) { entityState_t *oldent, *newent; int oldindex, newindex; int oldnum, newnum; int from_num_entities; // generate the delta update if ( !from ) { from_num_entities = 0; } else { from_num_entities = from->num_entities; } newent = NULL; oldent = NULL; newindex = 0; oldindex = 0; const int num2Send = to->num_entities >= svs.numSnapshotEntities ? svs.numSnapshotEntities : to->num_entities; while ( newindex < num2Send || oldindex < from_num_entities ) { if ( newindex >= num2Send ) { newnum = 9999; } else { newent = &svs.snapshotEntities[(to->first_entity+newindex) % svs.numSnapshotEntities]; newnum = newent->number; } if ( oldindex >= from_num_entities ) { oldnum = 9999; } else { oldent = &svs.snapshotEntities[(from->first_entity+oldindex) % svs.numSnapshotEntities]; oldnum = oldent->number; } if ( newnum == oldnum ) { // delta update from old position // because the force parm is qfalse, this will not result // in any bytes being emited if the entity has not changed at all MSG_WriteEntity(msg, newent, 0); oldindex++; newindex++; continue; } if ( newnum < oldnum ) { // this is a new entity, send it from the baseline MSG_WriteEntity (msg, newent, 0); newindex++; continue; } if ( newnum > oldnum ) { // the old entity isn't present in the new message if(oldent) { MSG_WriteEntity (msg, NULL, oldent->number); } oldindex++; continue; } } MSG_WriteBits( msg, (MAX_GENTITIES-1), GENTITYNUM_BITS ); // end of packetentities }