From 1a60664ab9134828667c6bc351834fe711e9a5d7 Mon Sep 17 00:00:00 2001 From: Spoike Date: Wed, 19 Oct 2005 21:12:49 +0000 Subject: [PATCH] Optimised and fixed >512 entities. git-svn-id: https://svn.code.sf.net/p/fteqw/code/trunk@1505 fc73d0e0-1445-4013-8a0c-d673dee63da5 --- engine/server/sv_ents.c | 40 +++++++++++++++++++++++++++++++++++----- 1 file changed, 35 insertions(+), 5 deletions(-) diff --git a/engine/server/sv_ents.c b/engine/server/sv_ents.c index 82ef4f8ba..8b463d5ad 100644 --- a/engine/server/sv_ents.c +++ b/engine/server/sv_ents.c @@ -712,12 +712,32 @@ void SV_EmitPacketEntities (client_t *client, packet_entities_t *to, sizebuf_t * if (newnum > oldnum) { // the old entity isn't present in the new message //Con_Printf ("remove %i\n", oldnum); - MSG_WriteShort (msg, oldnum | U_REMOVE); + if (oldnum > 512) + { + //yup, this is expensive. + MSG_WriteShort (msg, oldnum | U_REMOVE|U_MOREBITS); + MSG_WriteByte (msg, U_EVENMORE); + if (oldnum >= 1024) + { + if (oldnum >= 1024+512) + MSG_WriteByte (msg, U_ENTITYDBL2); + else + MSG_WriteByte (msg, U_ENTITYDBL|U_ENTITYDBL2); + } + else + MSG_WriteByte (msg, U_ENTITYDBL); + } + else + MSG_WriteShort (msg, oldnum | U_REMOVE); + oldindex++; continue; } } + if (newindex > to->max_entities) + Con_Printf("Exceeded max entities\n"); + MSG_WriteShort (msg, 0); // end of packetentities } #ifdef NQPROT @@ -2361,10 +2381,20 @@ void SV_WriteEntitiesToClient (client_t *client, sizebuf_t *msg, qboolean ignore //the entity would mess up the client and possibly disconnect them. //FIXME: add an option to drop clients... entity fog could be killed in this way. - if (e >= 512 && !(client->fteprotocolextensions & PEXT_ENTITYDBL)) - continue; - if (e >= 1024 && !(client->fteprotocolextensions & PEXT_ENTITYDBL2)) - continue; + if (e >= 512) + { + if (!(client->fteprotocolextensions & PEXT_ENTITYDBL)) + { + continue; + } + else if (e >= 1024) + { + if (!(client->fteprotocolextensions & PEXT_ENTITYDBL2)) + continue; + else if (e >= 2048) + continue; + } + } if (ent->v->modelindex >= 256 && !(client->fteprotocolextensions & PEXT_MODELDBL)) continue;