// if it is the player, update urgently
if (stateindex == d->viewentnum)
return E5_PROTOCOL_PRIORITYLEVELS - 1;
- priority = d->priorities[stateindex];
+ // priority increases each frame no matter what happens
+ priority = d->priorities[stateindex] + 1;
+ // players get an extra priority boost
+ if (stateindex <= svs.maxclients)
+ priority++;
// remove dead entities very quickly because they are just 2 bytes
if (!d->states[stateindex].active)
- return bound(1, priority + 1, E5_PROTOCOL_PRIORITYLEVELS - 1);
+ {
+ priority++;
+ return bound(1, priority, E5_PROTOCOL_PRIORITYLEVELS - 1);
+ }
changedbits = d->deltabits[stateindex];
// find the root entity this one is attached to, and judge relevance by it
for (limit = 0;limit < 256;limit++)
Con_DPrintf("Protocol: Runaway loop recursing tagentity links on entity %i\n", stateindex);
// now that we have the parent entity we can make some decisions based on
// distance and other factors
- // TODO: add velocity check for things moving toward you (+1 priority)
+ // note: this origin check does not work properly on doors/lifts whose
+ // origin is normally far away
distance = VectorDistance(d->states[d->viewentnum].origin, s->origin);
- // if it is not far from the player, update more often
- if (distance < 256.0f)
- priority++;
// if it is not very far from the player, update more often
if (distance < 1024.0f)
priority++;
// certain changes are more noticable than others
if (changedbits & E5_FULLUPDATE)
priority++;
- if (changedbits & (E5_ATTACHMENT | E5_MODEL | E5_FLAGS | E5_COLORMAP))
+ else if (changedbits & (E5_ATTACHMENT | E5_MODEL | E5_FLAGS | E5_COLORMAP))
priority++;
return (int) bound(1, priority, E5_PROTOCOL_PRIORITYLEVELS - 1);
}
if (bits)
{
d->deltabits[s->number] |= bits;
- d->priorities[s->number] = 1;
+ // if it was a very important update, set priority higher
+ if (bits & (E5_FULLUPDATE | E5_ATTACHMENT | E5_MODEL || E5_COLORMAP))
+ d->priorities[s->number] = max(d->priorities[s->number], 4);
+ else
+ d->priorities[s->number] = max(d->priorities[s->number], 1);
}
}
// mark lost stats
{
CLEARPVSBIT(d->visiblebits, num);
d->deltabits[num] = E5_FULLUPDATE;
- d->priorities[num] = E5_PROTOCOL_PRIORITYLEVELS - 1;
+ d->priorities[num] = max(d->priorities[num], 8); // removal is cheap
d->states[num] = defaultstate;
d->states[num].number = num;
}
// entity just spawned in, don't let it completely hog priority
// because of being ancient on the first frame
d->updateframenum[num] = framenum;
+ // initial priority is a bit high to make projectiles send on the
+ // first frame, among other things
+ d->priorities[num] = max(d->priorities[num], 4);
}
SETPVSBIT(d->visiblebits, num);
d->deltabits[num] |= EntityState5_DeltaBits(d->states + num, n);
- d->priorities[num] = 1;
d->states[num] = *n;
d->states[num].number = num;
// advance to next entity so the next iteration doesn't immediately remove it
{
CLEARPVSBIT(d->visiblebits, num);
d->deltabits[num] = E5_FULLUPDATE;
- d->priorities[num] = E5_PROTOCOL_PRIORITYLEVELS - 1;
+ d->priorities[num] = max(d->priorities[num], 8); // removal is cheap
d->states[num] = defaultstate;
d->states[num].number = num;
}
if (d->priorities[num])
{
if (d->priorities[num] < (E5_PROTOCOL_PRIORITYLEVELS - 1))
- {
- d->priorities[num]++;
d->priorities[num] = EntityState5_Priority(d, num);
- }
l = num;
priority = d->priorities[num];
if (entityframe5_prioritychaincounts[priority] < ENTITYFRAME5_MAXSTATES)