]> de.git.xonotic.org Git - xonotic/darkplaces.git/blobdiff - protocol.c
make compile on MSVC
[xonotic/darkplaces.git] / protocol.c
index cb7fda68e3bec8f254eef5ec4779eeef022e7f56..7ae6db28d62ee4b4a34a9b365538f5bea4a73455 100644 (file)
@@ -45,16 +45,16 @@ struct
 protocolversioninfo[] =
 {
        {0, "UNKNOWN"},
-       {15, "QUAKE"},
+       {3504, "DP7"},
+       {3503, "DP6"},
+       {3502, "DP5"},
+       {3501, "DP4"},
+       {3500, "DP3"},
+       {97, "DP2"},
+       {96, "DP1"},
        {15, "QUAKEDP"},
        {250, "NEHAHRAMOVIE"},
-       {96, "DARKPLACES1"},
-       {97, "DARKPLACES2"},
-       {3500, "DARKPLACES3"},
-       {3501, "DARKPLACES4"},
-       {3502, "DARKPLACES5"},
-       {3503, "DARKPLACES6"},
-       {3504, "DARKPLACES7"},
+       {15, "QUAKE"},
        {0, NULL}
 };
 
@@ -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)))
                        {