return;
lastentity = cl_lastquakeentity;
cl_lastquakeentity = 0;
- for (num = 0;num < lastentity;num++)
+ for (num = 0;num <= lastentity;num++)
{
if (cl_isquakeentity[num])
{
- cl_isquakeentity[num] = false;
- if (cl_entities_active[num])
+ if (cl_entities_active[num] && cl_entities[num].state_current.time == cl.mtime[0])
{
- if (cl_entities[num].state_current.time == cl.mtime[0])
- {
- cl_isquakeentity[num] = true;
- cl_lastquakeentity = num;
- }
- else
- {
- cl_isquakeentity[num] = false;
- cl_entities_active[num] = false;
- cl_entities[num].state_current = defaultstate;
- cl_entities[num].state_current.number = num;
- }
+ cl_isquakeentity[num] = true;
+ cl_lastquakeentity = num;
+ }
+ else
+ {
+ cl_isquakeentity[num] = false;
+ cl_entities_active[num] = false;
+ cl_entities[num].state_current = defaultstate;
+ cl_entities[num].state_current.number = num;
}
}
}
e->origin[2] = MSG_ReadCoord32f();
}
}
+ else
+ Host_Error("EntityState_ReadFields: unknown cl.protocol %i\n", cl.protocol);
if (cl.protocol == PROTOCOL_DARKPLACES5 && !(e->flags & RENDER_LOWPRECISION))
{
if (bits & E_ANGLE1)
void EntityFrame_AckFrame(entityframe_database_t *d, int frame)
{
int i;
- if (d->ackframenum < frame)
- d->ackframenum = frame;
+ d->ackframenum = frame;
for (i = 0;i < d->numframes && d->frames[i].framenum < frame;i++);
// ignore outdated frame acks (out of order packets)
if (i == 0)
EntityFrame_AddFrame(d, eye, d->latestframenum, numstates, states);
- EntityFrame_FetchFrame(d, d->ackframenum > 0 ? d->ackframenum : -1, o);
+ EntityFrame_FetchFrame(d, d->ackframenum, o);
MSG_WriteByte (msg, svc_entities);
MSG_WriteLong (msg, o->framenum);
// read the frame header info
f->time = cl.mtime[0];
number = MSG_ReadLong();
- f->framenum = MSG_ReadLong();
+ cl.latestframenum = f->framenum = MSG_ReadLong();
f->eye[0] = MSG_ReadFloat();
f->eye[1] = MSG_ReadFloat();
f->eye[2] = MSG_ReadFloat();
d = Mem_Alloc(pool, sizeof(*d));
d->mempool = pool;
EntityFrame4_ResetDatabase(d);
- d->ackframenum = -1;
return d;
}
void EntityFrame4_ResetDatabase(entityframe4_database_t *d)
{
int i;
- d->ackframenum = -1;
d->referenceframenum = -1;
for (i = 0;i < MAX_ENTITY_HISTORY;i++)
d->commit[i].numentities = 0;
d->referenceentity[i] = defaultstate;
}
-int EntityFrame4_AckFrame(entityframe4_database_t *d, int framenum)
+int EntityFrame4_AckFrame(entityframe4_database_t *d, int framenum, int servermode)
{
int i, j, found;
entity_database4_commit_t *commit;
d->referenceframenum = -1;
for (i = 0;i < d->maxreferenceentities;i++)
d->referenceentity[i] = defaultstate;
+ // if this is the server, remove commits
+ for (i = 0, commit = d->commit;i < MAX_ENTITY_HISTORY;i++, commit++)
+ commit->numentities = 0;
found = true;
}
else if (d->referenceframenum == framenum)
// read the number of the frame this refers to
referenceframenum = MSG_ReadLong();
// read the number of this frame
- framenum = MSG_ReadLong();
+ cl.latestframenum = framenum = MSG_ReadLong();
// read the start number
enumber = (unsigned short) MSG_ReadShort();
if (developer_networkentities.integer >= 1)
Con_Printf(" %i", d->commit[i].framenum);
Con_Print("\n");
}
- if (!EntityFrame4_AckFrame(d, referenceframenum))
+ if (!EntityFrame4_AckFrame(d, referenceframenum, false))
{
Con_Print("EntityFrame4_CL_ReadFrame: reference frame invalid (VERY BAD ERROR), this update will be skipped\n");
skip = true;
if (!d->commit[i].numentities)
{
d->currentcommit = d->commit + i;
- d->currentcommit->framenum = d->ackframenum = framenum;
+ d->currentcommit->framenum = framenum;
d->currentcommit->numentities = 0;
}
}
int i;
memset(d, 0, sizeof(*d));
d->latestframenum = 0;
- d->ackframenum = -1;
for (i = 0;i < MAX_EDICTS;i++)
d->states[i] = defaultstate;
}
int i, j, k, l, bits;
entityframe5_changestate_t *s, *s2;
entityframe5_packetlog_t *p, *p2;
- if (framenum <= d->ackframenum)
- return;
- d->ackframenum = framenum;
// scan for packets made obsolete by this ack
for (i = 0, p = d->packetlog;i < ENTITYFRAME5_MAXPACKETLOGS;i++, p++)
{