data = entdata;
if (!data)
return;
- if (!COM_ParseToken(&data, false))
+ if (!COM_ParseTokenConsole(&data))
return; // error
if (com_token[0] != '{')
return; // error
while (1)
{
- if (!COM_ParseToken(&data, false))
+ if (!COM_ParseTokenConsole(&data))
return; // error
if (com_token[0] == '}')
break; // end of worldspawn
strlcpy (key, com_token, sizeof (key));
while (key[strlen(key)-1] == ' ') // remove trailing spaces
key[strlen(key)-1] = 0;
- if (!COM_ParseToken(&data, false))
+ if (!COM_ParseTokenConsole(&data))
return; // error
strlcpy (value, com_token, sizeof (value));
if (!strcmp("sky", key))
cl.stats[STAT_ITEMS] = MSG_ReadLong ();
cl.onground = (bits & SU_ONGROUND) != 0;
- csqc_onground = cl.onground; //[515]: cause without this csqc will receive not right value on svc_print =/
cl.inwater = (bits & SU_INWATER) != 0;
if (cls.protocol == PROTOCOL_DARKPLACES5)
// viewzoom interpolation
cl.mviewzoom[0] = (float) max(cl.stats[STAT_VIEWZOOM], 2) * (1.0f / 255.0f);
+
+ // force a recalculation of the player prediction
+ cl.movement_replay = true;
}
/*
CL_Effect(org, modelindex, startframe, framecount, framerate);
}
-void CL_ParseBeam (model_t *m, int lightning)
+void CL_NewBeam (int ent, vec3_t start, vec3_t end, model_t *m, int lightning)
{
- int i, ent;
- vec3_t start, end;
+ int i;
beam_t *b = NULL;
- ent = (unsigned short) MSG_ReadShort ();
- MSG_ReadVector(start, cls.protocol);
- MSG_ReadVector(end, cls.protocol);
-
if (ent >= MAX_EDICTS)
{
- Con_Printf("CL_ParseBeam: invalid entity number %i\n", ent);
+ Con_Printf("CL_NewBeam: invalid entity number %i\n", ent);
ent = 0;
}
// if the entity was not found then just replace an unused beam
if (i == cl.max_beams)
for (i = 0, b = cl.beams;i < cl.max_beams;i++, b++)
- if (!b->model || b->endtime < cl.time)
+ if (!b->model)
break;
if (i < cl.max_beams)
{
b->entity = ent;
b->lightning = lightning;
b->model = m;
- b->endtime = cl.time + 0.2;
+ b->endtime = cl.mtime[0] + 0.2;
VectorCopy (start, b->start);
VectorCopy (end, b->end);
- b->relativestartvalid = 0;
- if (ent && cl.entities[ent].state_current.active)
- {
- entity_state_t *p;
- matrix4x4_t matrix, imatrix;
- if (ent == cl.viewentity && cl.movement)
- p = &cl.entities[b->entity].state_previous;
- else
- p = &cl.entities[b->entity].state_current;
- // not really valid yet, we need to get the orientation now
- // (ParseBeam flagged this because it is received before
- // entities are received, by now they have been received)
- // note: because players create lightning in their think
- // function (which occurs before movement), they actually
- // have some lag in it's location, so compare to the
- // previous player state, not the latest
- Matrix4x4_CreateFromQuakeEntity(&matrix, p->origin[0], p->origin[1], p->origin[2], -p->angles[0], p->angles[1], p->angles[2], 1);
- Matrix4x4_Invert_Simple(&imatrix, &matrix);
- Matrix4x4_Transform(&imatrix, b->start, b->relativestart);
- Matrix4x4_Transform(&imatrix, b->end, b->relativeend);
- b->relativestartvalid = 1;
- }
}
else
Con_Print("beam list overflow!\n");
}
+void CL_ParseBeam (model_t *m, int lightning)
+{
+ int ent;
+ vec3_t start, end;
+
+ ent = (unsigned short) MSG_ReadShort ();
+ MSG_ReadVector(start, cls.protocol);
+ MSG_ReadVector(end, cls.protocol);
+
+ if (ent >= MAX_EDICTS)
+ {
+ Con_Printf("CL_ParseBeam: invalid entity number %i\n", ent);
+ ent = 0;
+ }
+
+ CL_NewBeam(ent, start, end, m, lightning);
+}
+
void CL_ParseTempEntity(void)
{
int type;
}
}
+// look for anything interesting like player IP addresses or ping reports
+qboolean CL_ExaminePrintString(const char *text)
+{
+ const char *t;
+ if (!strcmp(text, "Client ping times:\n"))
+ {
+ cl.parsingtextmode = CL_PARSETEXTMODE_PING;
+ for(cl.parsingtextplayerindex = 0; cl.parsingtextplayerindex < cl.maxclients && !cl.scores[cl.parsingtextplayerindex].name[0]; cl.parsingtextplayerindex++)
+ ;
+ if (cl.parsingtextplayerindex >= cl.maxclients) // should never happen, since the client itself should be in cl.scores
+ {
+ Con_Printf("ping reply but empty scoreboard?!?\n");
+ cl.parsingtextmode = CL_PARSETEXTMODE_NONE;
+ cl.parsingtextexpectingpingforscores = 0;
+ }
+ cl.parsingtextexpectingpingforscores = cl.parsingtextexpectingpingforscores ? 2 : 0;
+ return !cl.parsingtextexpectingpingforscores;
+ }
+ if (!strncmp(text, "host: ", 9))
+ {
+ // cl.parsingtextexpectingpingforscores = false; // really?
+ cl.parsingtextmode = CL_PARSETEXTMODE_STATUS;
+ cl.parsingtextplayerindex = 0;
+ return true;
+ }
+ if (cl.parsingtextmode == CL_PARSETEXTMODE_PING)
+ {
+ // if anything goes wrong, we'll assume this is not a ping report
+ qboolean expected = cl.parsingtextexpectingpingforscores;
+ cl.parsingtextexpectingpingforscores = 0;
+ cl.parsingtextmode = CL_PARSETEXTMODE_NONE;
+ t = text;
+ while (*t == ' ')
+ t++;
+ if ((*t >= '0' && *t <= '9') || *t == '-')
+ {
+ int ping = atoi(t);
+ while ((*t >= '0' && *t <= '9') || *t == '-')
+ t++;
+ if (*t == ' ')
+ {
+ int charindex = 0;
+ t++;
+ if(cl.parsingtextplayerindex < cl.maxclients)
+ {
+ for (charindex = 0;cl.scores[cl.parsingtextplayerindex].name[charindex] == t[charindex];charindex++)
+ ;
+ if (cl.scores[cl.parsingtextplayerindex].name[charindex] == 0 && t[charindex] == '\n')
+ {
+ cl.scores[cl.parsingtextplayerindex].qw_ping = bound(0, ping, 9999);
+ for (cl.parsingtextplayerindex++;cl.parsingtextplayerindex < cl.maxclients && !cl.scores[cl.parsingtextplayerindex].name[0];cl.parsingtextplayerindex++)
+ ;
+ //if (cl.parsingtextplayerindex < cl.maxclients) // we could still get unconnecteds!
+ {
+ // we parsed a valid ping entry, so expect another to follow
+ cl.parsingtextmode = CL_PARSETEXTMODE_PING;
+ cl.parsingtextexpectingpingforscores = expected;
+ }
+ return !expected;
+ }
+ }
+ if (!strncmp(t, "unconnected\n", 12))
+ {
+ // just ignore
+ cl.parsingtextmode = CL_PARSETEXTMODE_PING;
+ cl.parsingtextexpectingpingforscores = expected;
+ return !expected;
+ }
+ else
+ Con_DPrintf("player names '%s' and '%s' didn't match\n", cl.scores[cl.parsingtextplayerindex].name, t);
+ }
+ }
+ }
+ if (cl.parsingtextmode == CL_PARSETEXTMODE_STATUS)
+ {
+ if (!strncmp(text, "players: ", 9))
+ {
+ cl.parsingtextmode = CL_PARSETEXTMODE_STATUS_PLAYERID;
+ cl.parsingtextplayerindex = 0;
+ return true;
+ }
+ else if (!strstr(text, ": "))
+ {
+ cl.parsingtextmode = CL_PARSETEXTMODE_NONE; // status report ended
+ return true;
+ }
+ }
+ if (cl.parsingtextmode == CL_PARSETEXTMODE_STATUS_PLAYERID)
+ {
+ // if anything goes wrong, we'll assume this is not a status report
+ cl.parsingtextmode = CL_PARSETEXTMODE_NONE;
+ if (text[0] == '#' && text[1] >= '0' && text[1] <= '9')
+ {
+ t = text + 1;
+ cl.parsingtextplayerindex = atoi(t);
+ while (*t >= '0' && *t <= '9')
+ t++;
+ if (*t == ' ')
+ {
+ cl.parsingtextmode = CL_PARSETEXTMODE_STATUS_PLAYERIP;
+ return true;
+ }
+ }
+ }
+ if (cl.parsingtextmode == CL_PARSETEXTMODE_STATUS_PLAYERIP)
+ {
+ // if anything goes wrong, we'll assume this is not a status report
+ cl.parsingtextmode = CL_PARSETEXTMODE_NONE;
+ if (text[0] == ' ')
+ {
+ t = text;
+ while (*t == ' ')
+ t++;
+ // botclient is perfectly valid, but we don't care about bots
+ if (strcmp(t, "botclient\n"))
+ {
+ lhnetaddress_t address;
+ LHNETADDRESS_FromString(&address, t, 0);
+ // TODO: log the IP address and player name?
+ }
+ cl.parsingtextmode = CL_PARSETEXTMODE_STATUS_PLAYERID;
+ return true;
+ }
+ }
+ return true;
+}
+
#define SHOWNET(x) if(cl_shownet.integer==2)Con_Printf("%3i:%s\n", msg_readcount-1, x);
//[515]: csqc
cl.mtime[1] = cl.mtime[0];
cl.mtime[0] = realtime; // qw has no clock
cl.movement_needupdate = true;
+ cl.onground = false; // since there's no clientdata parsing, clear the onground flag here
// if true the cl.viewangles are interpolated from cl.mviewangles[]
// during this frame
// (makes spectating players much smoother and prevents mouse movement from turning)
if (!cls.demoplayback)
VectorCopy(cl.mviewangles[0], cl.mviewangles[1]);
+ // force a recalculation of the player prediction
+ cl.movement_replay = true;
+
// slightly kill qw player entities each frame
for (i = 1;i < cl.maxclients;i++)
cl.entities_active[i] = false;
{
char description[32*64], temp[64];
int count;
- strcpy(description, "packet dump: ");
+ strlcpy(description, "packet dump: ", sizeof(description));
i = cmdcount - 32;
if (i < 0)
i = 0;
case qw_svc_print:
i = MSG_ReadByte();
- if (i == 3) // chat
- CSQC_AddPrintText(va("\1%s", MSG_ReadString())); //[515]: csqc
- else
- CSQC_AddPrintText(MSG_ReadString());
+ temp = MSG_ReadString();
+ if (CL_ExaminePrintString(temp)) // look for anything interesting like player IP addresses or ping reports
+ {
+ if (i == 3) // chat
+ CSQC_AddPrintText(va("\1%s", temp)); //[515]: csqc
+ else
+ CSQC_AddPrintText(temp);
+ }
break;
case qw_svc_centerprint:
if (i >= cl.maxclients)
Host_Error("CL_ParseServerMessage: svc_updateentertime >= cl.maxclients");
// seconds ago
- cl.scores[i].qw_entertime = realtime - MSG_ReadFloat();
+ cl.scores[i].qw_entertime = cl.time - MSG_ReadFloat();
break;
case qw_svc_spawnbaseline:
{
char description[32*64], temp[64];
int count;
- strcpy (description, "packet dump: ");
+ strlcpy (description, "packet dump: ", sizeof(description));
i = cmdcount - 32;
if (i < 0)
i = 0;
break;
case svc_print:
- CSQC_AddPrintText(MSG_ReadString()); //[515]: csqc
+ temp = MSG_ReadString();
+ if (CL_ExaminePrintString(temp)) // look for anything interesting like player IP addresses or ping reports
+ CSQC_AddPrintText(temp); //[515]: csqc
break;
case svc_centerprint: