]> de.git.xonotic.org Git - xonotic/darkplaces.git/commitdiff
fix stupid bug in last patch that made entities not update
authorhavoc <havoc@d7cf8633-e32d-0410-b094-e92efae38249>
Sat, 10 Feb 2007 21:17:06 +0000 (21:17 +0000)
committerhavoc <havoc@d7cf8633-e32d-0410-b094-e92efae38249>
Sat, 10 Feb 2007 21:17:06 +0000 (21:17 +0000)
reworked priorities some more

git-svn-id: svn://svn.icculus.org/twilight/trunk/darkplaces@6818 d7cf8633-e32d-0410-b094-e92efae38249

protocol.c

index f5d322c580d14e9a97b25c1e3dac7954f18c04b0..46408a59258a411b7f612871ed80b5b77239d7e0 100644 (file)
@@ -1646,8 +1646,6 @@ void EntityFrame5_ExpandEdicts(entityframe5_database_t *d, int newmax)
 int EntityState5_Priority(entityframe5_database_t *d, int stateindex)
 {
        int limit, priority;
-       double distance;
-       int changedbits;
        entity_state_t *s;
        // if it is the player, update urgently
        if (stateindex == d->viewentnum)
@@ -1663,7 +1661,9 @@ int EntityState5_Priority(entityframe5_database_t *d, int stateindex)
                priority++;
                return bound(1, priority, E5_PROTOCOL_PRIORITYLEVELS - 1);
        }
-       changedbits = d->deltabits[stateindex];
+       // certain changes are more noticable than others
+       if (d->deltabits[stateindex] & (E5_FULLUPDATE | E5_ATTACHMENT | E5_MODEL | E5_FLAGS | E5_COLORMAP))
+               priority++;
        // find the root entity this one is attached to, and judge relevance by it
        for (limit = 0;limit < 256;limit++)
        {
@@ -1680,19 +1680,10 @@ int EntityState5_Priority(entityframe5_database_t *d, int stateindex)
        if (limit >= 256)
                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
-       // 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 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++;
-       else if (changedbits & (E5_ATTACHMENT | E5_MODEL | E5_FLAGS | E5_COLORMAP))
+       // distance from the player
+       if (VectorDistance(d->states[d->viewentnum].origin, s->origin) < 1024.0f)
                priority++;
-       return (int) bound(1, priority, E5_PROTOCOL_PRIORITYLEVELS - 1);
+       return bound(1, priority, E5_PROTOCOL_PRIORITYLEVELS - 1);
 }
 
 void EntityState5_WriteUpdate(int number, const entity_state_t *s, int changedbits, sizebuf_t *msg)
@@ -2240,6 +2231,7 @@ void EntityFrame5_WriteFrame(sizebuf_t *msg, entityframe5_database_t *d, int num
                }
                SETPVSBIT(d->visiblebits, num);
                d->deltabits[num] |= EntityState5_DeltaBits(d->states + num, n);
+               d->priorities[num] = max(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