- make SV_ReliableSVC_Emit mark overflowed clients as such, and die if

we ever giet a NET_ERROR
- fix the baselines so all entities have the QSG2 extensions (alpha,
  scale, etc) inited, instead of just the entities that the map
  started with
- make the server not include empty deltas in a
  svc_deltapacketentities for updated entities
- change a silly for (; foo;) to while (foo)
This commit is contained in:
Adam Olsen 2001-12-05 15:41:25 +00:00
parent f646786bf5
commit 3fdad3ce45
5 changed files with 54 additions and 22 deletions

View file

@ -537,7 +537,7 @@ void SV_WriteEntitiesToClient (client_t *client, sizebuf_t *msg);
//
// sv_nchan.c
//
net_status_t SV_ReliableSVC_Emit (client_t *cl, int type, void *block);
void SV_ReliableSVC_Emit (client_t *cl, int type, void *block);
void ClientReliableCheckBlock(client_t *cl, int maxsize);
void ClientReliable_FinishWrite(client_t *cl);
void ClientReliableWrite_Begin(client_t *cl, int c, int maxsize);

View file

@ -263,7 +263,7 @@ CL_ParseDeltaPacketEntities (net_svc_deltapacketentities_t *block)
newp->num_entities = 0;
for (; block->words[wordindex];) {
while (block->words[wordindex]) {
newnum = block->words[wordindex] & 511;
oldnum = oldindex >= oldp->num_entities ? 9999 :
oldp->entities[oldindex].number;

View file

@ -259,7 +259,7 @@ SV_EmitDeltaPacketEntities (client_t *client, packet_entities_t *to,
sizebuf_t *msg)
{
int newindex, oldindex, newnum, oldnum;
int word;
int word, delta;
entity_state_t *baseline;
packet_entities_t *from;
net_svc_deltapacketentities_t block;
@ -271,9 +271,8 @@ SV_EmitDeltaPacketEntities (client_t *client, packet_entities_t *to,
// SV_Printf ("---%i to %i ----\n", client->delta_sequence & UPDATE_MASK,
// client->netchan.outgoing_sequence & UPDATE_MASK);
for (newindex = 0, oldindex = 0, word = 0;
newindex < to->num_entities || oldindex < from->num_entities;
word++) {
for (newindex = 0, oldindex = 0, word = 0, delta = 0;
newindex < to->num_entities || oldindex < from->num_entities;) {
newnum = newindex >= to->num_entities ?
9999 : to->entities[newindex].number;
oldnum = oldindex >= from->num_entities ?
@ -281,39 +280,50 @@ SV_EmitDeltaPacketEntities (client_t *client, packet_entities_t *to,
if (newnum == oldnum) { // delta update from old position
// SV_Printf ("delta %i\n", newnum);
block.deltas[newindex] = to->entities[newindex];
block.deltas[newindex].flags =
block.deltas[delta] = to->entities[newindex];
block.deltas[delta].flags =
SV_EntityState_Diff (&from->entities[oldindex],
&to->entities[newindex]);
// check if it's a client that doesn't support QSG2
if (client->stdver <= 1)
block.deltas[newindex].flags &= U_VERSION_ID;
block.deltas[delta].flags &= U_VERSION_ID;
block.words[word] = newnum | (block.deltas[newindex].flags & ~511);
if (!block.deltas[delta].flags) { // no updates to send
oldindex++;
newindex++;
continue;
}
block.words[word] = newnum | (block.deltas[delta].flags & ~511);
oldindex++;
newindex++;
word++;
delta++;
} else if (newnum < oldnum) { // this is a new entity, send
// it from the baseline
baseline = EDICT_NUM (&sv_pr_state, newnum)->data;
// SV_Printf ("baseline %i\n", newnum);
block.deltas[newindex] = to->entities[newindex];
block.deltas[newindex].flags =
block.deltas[delta] = to->entities[newindex];
block.deltas[delta].flags =
SV_EntityState_Diff (baseline, &to->entities[newindex]);
// check if it's a client that doesn't support QSG2
if (client->stdver <= 1)
block.deltas[newindex].flags &= U_VERSION_ID;
block.deltas[delta].flags &= U_VERSION_ID;
block.words[word] = newnum | (block.deltas[newindex].flags & ~511);
block.words[word] = newnum | (block.deltas[delta].flags & ~511);
newindex++;
word++;
delta++;
} else if (newnum > oldnum) { // the old entity isn't
// present in the new message
// SV_Printf ("remove %i\n", oldnum);
block.words[word] = oldnum | U_REMOVE;
oldindex++;
word++;
}
}

View file

@ -109,6 +109,19 @@ SV_CreateBaseline (void)
edict_t *svent;
net_svc_spawnbaseline_t block;
// setup the default baselines
memset (baselines, 0, sizeof (baselines));
for (entnum = 0; entnum < MAX_EDICTS; entnum++) {
svent = EDICT_NUM (&sv_pr_state, entnum);
// LordHavoc: setup baseline to include new effects
((entity_state_t*)svent->data)->alpha = 255;
((entity_state_t*)svent->data)->scale = 16;
((entity_state_t*)svent->data)->glow_size = 0;
((entity_state_t*)svent->data)->glow_color = 254;
((entity_state_t*)svent->data)->colormod = 255;
}
// setup the baselines for map entities
for (entnum = 0; entnum < sv.num_edicts; entnum++) {
svent = EDICT_NUM (&sv_pr_state, entnum);
if (svent->free)
@ -134,12 +147,6 @@ SV_CreateBaseline (void)
((entity_state_t*)svent->data)->modelindex =
SV_ModelIndex (PR_GetString (&sv_pr_state, SVstring (svent, model)));
}
// LordHavoc: setup baseline to include new effects
((entity_state_t*)svent->data)->alpha = 255;
((entity_state_t*)svent->data)->scale = 16;
((entity_state_t*)svent->data)->glow_size = 0;
((entity_state_t*)svent->data)->glow_color = 254;
((entity_state_t*)svent->data)->colormod = 255;
// flush the signon message out to a seperate buffer if nearly full
SV_FlushSignon ();

View file

@ -39,6 +39,7 @@ static const char rcsid[] =
#include "QF/msg.h"
#include "QF/net_svc.h"
#include "QF/sys.h"
#include "server.h"
@ -55,7 +56,7 @@ PushBackbuf (client_t *cl)
cl->num_backbuf++;
}
net_status_t
void
SV_ReliableSVC_Emit (client_t *cl, int type, void *block)
{
net_status_t retval;
@ -75,7 +76,21 @@ SV_ReliableSVC_Emit (client_t *cl, int type, void *block)
PushBackbuf (cl);
retval = NET_SVC_Emit (type, block, &cl->backbuf);
}
return retval;
switch (retval) {
case NET_SHORT:
SV_Printf ("SV_ReliableSVC_Emit: WARNING: reliable "
"overflow for %s with %d (%s) block\n",
cl->name, type, NET_SVC_GetString (type));
cl->netchan.message.overflowed = true;
break;
case NET_ERROR:
Sys_Error ("SV_ReliableSVC_Emit: error emitting %d (%s) "
"block for %s\n", type,
NET_SVC_GetString (type), cl->name);
break;
case NET_OK:
}
}