From: havoc Date: Sat, 10 Feb 2007 20:31:19 +0000 (+0000) Subject: fixed bug from lingering code that was resetting entity priority every frame X-Git-Tag: xonotic-v0.1.0preview~3597 X-Git-Url: http://git.xonotic.org/?a=commitdiff_plain;h=711e5209ab0e6ad3595decfca5974aa616db34ee;p=xonotic%2Fdarkplaces.git fixed bug from lingering code that was resetting entity priority every frame more tweaks to entity priority code git-svn-id: svn://svn.icculus.org/twilight/trunk/darkplaces@6817 d7cf8633-e32d-0410-b094-e92efae38249 --- diff --git a/protocol.c b/protocol.c index 561ca0e1..f5d322c5 100644 --- a/protocol.c +++ b/protocol.c @@ -1652,10 +1652,17 @@ int EntityState5_Priority(entityframe5_database_t *d, int stateindex) // 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++) @@ -1674,18 +1681,16 @@ int EntityState5_Priority(entityframe5_database_t *d, int stateindex) 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); } @@ -2131,7 +2136,11 @@ void EntityFrame5_LostFrame(entityframe5_database_t *d, int framenum) 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 @@ -2214,7 +2223,7 @@ void EntityFrame5_WriteFrame(sizebuf_t *msg, entityframe5_database_t *d, int num { 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; } @@ -2225,10 +2234,12 @@ void EntityFrame5_WriteFrame(sizebuf_t *msg, entityframe5_database_t *d, int 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 @@ -2241,7 +2252,7 @@ void EntityFrame5_WriteFrame(sizebuf_t *msg, entityframe5_database_t *d, int num { 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; } @@ -2260,10 +2271,7 @@ void EntityFrame5_WriteFrame(sizebuf_t *msg, entityframe5_database_t *d, int 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)