]> de.git.xonotic.org Git - xonotic/darkplaces.git/blobdiff - protocol.c
Urre admits he was inebriated and his judgment hencely impaired when he suggested...
[xonotic/darkplaces.git] / protocol.c
index 0c047113786c64c175eb50c2d7fcae42ebf1128b..7ae6db28d62ee4b4a34a9b365538f5bea4a73455 100644 (file)
@@ -270,7 +270,7 @@ void EntityFrameQuake_WriteFrame(sizebuf_t *msg, int numstates, const entity_sta
                        bits |= U_EXTERIORMODEL;
 
                // LordHavoc: old stuff, but rewritten to have more exact tolerances
-               baseline = sv.edicts[s->number].e->baseline;
+               baseline = prog->edicts[s->number].priv.server->baseline;
                if (baseline.origin[0] != s->origin[0])
                        bits |= U_ORIGIN1;
                if (baseline.origin[1] != s->origin[1])
@@ -639,23 +639,23 @@ void EntityState_ReadFields(entity_state_t *e, unsigned int bits)
                                e->origin[2] = MSG_ReadCoord32f();
                }
        }
-       if ((cl.protocol == PROTOCOL_DARKPLACES1 || cl.protocol == PROTOCOL_DARKPLACES2 || cl.protocol == PROTOCOL_DARKPLACES3 || cl.protocol == PROTOCOL_DARKPLACES4) && (e->flags & RENDER_LOWPRECISION))
+       if ((cl.protocol == PROTOCOL_DARKPLACES5 || cl.protocol == PROTOCOL_DARKPLACES6) && !(e->flags & RENDER_LOWPRECISION))
        {
                if (bits & E_ANGLE1)
-                       e->angles[0] = MSG_ReadAngle8i();
+                       e->angles[0] = MSG_ReadAngle16i();
                if (bits & E_ANGLE2)
-                       e->angles[1] = MSG_ReadAngle8i();
+                       e->angles[1] = MSG_ReadAngle16i();
                if (bits & E_ANGLE3)
-                       e->angles[2] = MSG_ReadAngle8i();
+                       e->angles[2] = MSG_ReadAngle16i();
        }
        else
        {
                if (bits & E_ANGLE1)
-                       e->angles[0] = MSG_ReadAngle16i();
+                       e->angles[0] = MSG_ReadAngle8i();
                if (bits & E_ANGLE2)
-                       e->angles[1] = MSG_ReadAngle16i();
+                       e->angles[1] = MSG_ReadAngle8i();
                if (bits & E_ANGLE3)
-                       e->angles[2] = MSG_ReadAngle16i();
+                       e->angles[2] = MSG_ReadAngle8i();
        }
        if (bits & E_MODEL1)
                e->modelindex = (e->modelindex & 0xFF00) | (unsigned int) MSG_ReadByte();
@@ -1381,15 +1381,15 @@ void EntityFrame4_WriteFrame(sizebuf_t *msg, entityframe4_database_t *d, int num
                                Con_Printf(" %i", d->commit[i].framenum);
                Con_Print(")\n");
        }
-       if (d->currententitynumber >= sv.max_edicts)
+       if (d->currententitynumber >= prog->max_edicts)
                startnumber = 1;
        else
-               startnumber = bound(1, d->currententitynumber, sv.max_edicts - 1);
+               startnumber = bound(1, d->currententitynumber, prog->max_edicts - 1);
        MSG_WriteShort(msg, startnumber);
        // reset currententitynumber so if the loop does not break it we will
        // start at beginning next frame (if it does break, it will set it)
        d->currententitynumber = 1;
-       for (i = 0, n = startnumber;n < sv.max_edicts;n++)
+       for (i = 0, n = startnumber;n < prog->max_edicts;n++)
        {
                // find the old state to delta from
                e = EntityFrame4_GetReferenceEntity(d, n);
@@ -2025,8 +2025,8 @@ void EntityFrame5_WriteFrame(sizebuf_t *msg, entityframe5_database_t *d, int num
        qbyte data[128];
        entityframe5_packetlog_t *packetlog;
 
-       if (sv.max_edicts > d->maxedicts)
-               EntityFrame5_ExpandEdicts(d, (sv.max_edicts + 255) & ~255);
+       if (prog->max_edicts > d->maxedicts)
+               EntityFrame5_ExpandEdicts(d, prog->max_edicts);
 
        framenum = d->latestframenum + 1;
        d->viewentnum = viewentnum;
@@ -2038,6 +2038,7 @@ void EntityFrame5_WriteFrame(sizebuf_t *msg, entityframe5_database_t *d, int num
                        break;
        if (packetlognumber == ENTITYFRAME5_MAXPACKETLOGS)
        {
+               Con_DPrintf("EntityFrame5_WriteFrame: packetlog overflow for a client, resetting\n");
                EntityFrame5_LostFrame(d, framenum);
                packetlognumber = 0;
        }
@@ -2090,8 +2091,7 @@ void EntityFrame5_WriteFrame(sizebuf_t *msg, entityframe5_database_t *d, int num
                num++;
        }
        // all remaining entities are dead
-       // note: this must use sv.max_edicts, not sv.num_edicts, because sv.num_edicts can both increase and decrease, where as sv.max_edicts only increases (if sv.num_edicts is used, sometimes some entities are missed when the sv.num_edicts count goes back down after firing some shots)
-       for (;num < sv.max_edicts;num++)
+       for (;num < d->maxedicts;num++)
        {
                if (CHECKPVSBIT(d->visiblebits, num))
                {
@@ -2103,10 +2103,15 @@ void EntityFrame5_WriteFrame(sizebuf_t *msg, entityframe5_database_t *d, int num
                }
        }
 
+       // if there isn't at least enough room for an empty svc_entities,
+       // don't bother trying...
+       if (buf.cursize + 11 > buf.maxsize)
+               return;
+
        // build lists of entities by priority level
        memset(entityframe5_prioritychaincounts, 0, sizeof(entityframe5_prioritychaincounts));
        l = 0;
-       for (num = 0;num < sv.num_edicts;num++)
+       for (num = 0;num < d->maxedicts;num++)
        {
                if (d->priorities[num])
                {
@@ -2124,7 +2129,7 @@ void EntityFrame5_WriteFrame(sizebuf_t *msg, entityframe5_database_t *d, int num
        // write stat updates
        if (sv.protocol != PROTOCOL_QUAKE && sv.protocol != PROTOCOL_QUAKEDP && sv.protocol != PROTOCOL_NEHAHRAMOVIE && sv.protocol != PROTOCOL_DARKPLACES1 && sv.protocol != PROTOCOL_DARKPLACES2 && sv.protocol != PROTOCOL_DARKPLACES3 && sv.protocol != PROTOCOL_DARKPLACES4 && sv.protocol != PROTOCOL_DARKPLACES5)
        {
-               for (i = 0;i < MAX_CL_STATS;i++)
+               for (i = 0;i < MAX_CL_STATS && msg->cursize + 6 + 11 <= msg->maxsize;i++)
                {
                        if (d->statsdeltabits[i>>3] & (1<<(i&7)))
                        {