add qsg support for players and actually send EFFECTS2 and FRAME2 for

packet entities
This commit is contained in:
Bill Currie 2002-06-19 02:55:57 +00:00
parent d2fadb2978
commit 5052e3db1f
4 changed files with 113 additions and 25 deletions

View file

@ -69,11 +69,8 @@ typedef struct player_state_s {
int oldbuttons;
// QSG2
byte alpha;
byte scale;
byte glow_size;
byte glow_color;
byte colormod;
} player_state_t;
#undef MAX_SCOREBOARDNAME

View file

@ -155,6 +155,16 @@
#define PF_GIB (1<<10) // offset the view height differently
#define PF_NOGRAV (1<<11) // don't apply gravity for prediction
#define PF_QF (1<<12) // QF QSG extension bits for players
#define PF_ALPHA (1<<0)
#define PF_SCALE (1<<1)
#define PF_EFFECTS2 (1<<2)
#define PF_GLOWSIZE (1<<3)
#define PF_GLOWCOLOR (1<<4)
#define PF_COLORMOD (1<<5)
#define PF_FRAME2 (1<<6)
//==============================================
// if the high bit of the client to server byte is set, the low bits are

View file

@ -676,6 +676,46 @@ CL_ParsePlayerinfo (void)
state->weaponframe = 0;
VectorCopy (state->command.angles, state->viewangles);
if (flags & PF_QF) {
// QSG2
int bits;
byte val;
entity_t *ent;
ent = &cl_player_ents[num];
bits = MSG_ReadByte (net_message);
if (bits & PF_ALPHA) {
val = MSG_ReadByte (net_message);
ent->colormod[3] = val / 255.0;
}
if (bits & PF_SCALE) {
val = MSG_ReadByte (net_message);
ent->scale = val / 16.0;
}
if (bits & PF_EFFECTS2) {
state->effects |= MSG_ReadByte (net_message) << 8;
}
if (bits & PF_GLOWSIZE) {
state->glow_size = MSG_ReadByte (net_message);
}
if (bits & PF_GLOWCOLOR) {
state->glow_color = MSG_ReadByte (net_message);
}
if (bits & PF_COLORMOD) {
val = MSG_ReadByte (net_message);
if (val == 255) {
ent->colormod[0] = ent->colormod[1] = ent->colormod[2] = 1.0;
} else {
ent->colormod[0] = (float) ((val >> 5) & 7) * (1.0 / 7.0);
ent->colormod[1] = (float) ((val >> 2) & 7) * (1.0 / 7.0);
ent->colormod[2] = (float) (val & 3) * (1.0 / 3.0);
}
}
if (bits & PF_FRAME2) {
state->frame |= MSG_ReadByte (net_message) << 8;
}
}
}
/*
@ -802,7 +842,8 @@ CL_LinkPlayers (void)
r_player_entity = &cl_player_ents[j];
} else
VectorCopy (state->origin, org);
CL_NewDlight (j, org, state->effects, 0, 255);
CL_NewDlight (j, org, state->effects, state->glow_size,
state->glow_color);
if (!state->modelindex)
continue;
@ -861,24 +902,6 @@ CL_LinkPlayers (void)
} else {
ent->skin = NULL;
}
// QSG2
#if 0
if (state->colormod == 255) {
ent->colormod[0] = ent->colormod[1] = ent->colormod[2] = 1.0;
} else {
ent->colormod[0] = (float) ((state->colormod >> 5) & 7) *
(1.0 / 7.0);
ent->colormod[1] = (float) ((state->colormod >> 2) & 7) *
(1.0 / 7.0);
ent->colormod[2] = (float) (state->colormod & 3) * (1.0 / 3.0);
}
ent->colormod[3] = state->alpha / 255.0;
ent->scale = state->scale / 16.0;
#else
ent->colormod[0] = ent->colormod[1] = ent->colormod[2] =
ent->colormod[3] = ent->scale = 1.0;
#endif
if (state->effects & EF_FLAG1)
CL_AddFlagModels (ent, 0, j);
else if (state->effects & EF_FLAG2)

View file

@ -210,6 +210,9 @@ SV_WriteDelta (entity_state_t *from, entity_state_t *to, sizebuf_t *msg,
if (to->scale != from->scale)
bits |= U_SCALE;
if (to->effects > 255)
bits |= U_EFFECTS2;
if (to->glow_size != from->glow_size)
bits |= U_GLOWSIZE;
@ -218,6 +221,9 @@ SV_WriteDelta (entity_state_t *from, entity_state_t *to, sizebuf_t *msg,
if (to->colormod != from->colormod)
bits |= U_COLORMOD;
if (to->frame > 255)
bits |= U_EFFECTS2;
}
if (bits >= 16777216)
@ -372,7 +378,7 @@ void
SV_WritePlayersToClient (client_t *client, edict_t *clent, byte * pvs,
sizebuf_t *msg)
{
int i, j, msec, pflags;
int i, j, msec, pflags, qf_bits;
client_t *cl;
edict_t *ent;
usercmd_t cmd;
@ -413,6 +419,27 @@ SV_WritePlayersToClient (client_t *client, edict_t *clent, byte * pvs,
if (SVvector (ent, mins)[2] != -24)
pflags |= PF_GIB;
qf_bits = 0;
if (client->stdver > 1) {
if (sv_fields.alpha != -1 && SVfloat (ent, alpha))
qf_bits |= PF_ALPHA;
if (sv_fields.scale != -1 && SVfloat (ent, scale))
qf_bits |= PF_SCALE;
if ((int) SVfloat (ent, effects) > 255)
qf_bits |= PF_EFFECTS2;
if (sv_fields.glow_size != -1 && SVfloat (ent, glow_size))
qf_bits |= PF_GLOWSIZE;
if (sv_fields.glow_color != -1 && SVfloat (ent, glow_color))
qf_bits |= PF_GLOWCOLOR;
if (sv_fields.colormod != -1
&& !VectorIsZero (SVvector (ent, colormod)))
qf_bits |= PF_COLORMOD;
if ((int) SVfloat (ent, frame) > 255)
qf_bits |= PF_EFFECTS2;
if (qf_bits)
pflags |= PF_QF;
}
if (cl->spectator) { // only sent origin and velocity to
// spectators
pflags &= PF_VELOCITY1 | PF_VELOCITY2 | PF_VELOCITY3;
@ -423,8 +450,9 @@ SV_WritePlayersToClient (client_t *client, edict_t *clent, byte * pvs,
pflags |= PF_WEAPONFRAME;
}
if (client->spec_track && client->spec_track - 1 == j &&
SVfloat (ent, weaponframe)) pflags |= PF_WEAPONFRAME;
if (client->spec_track && client->spec_track - 1 == j
&& SVfloat (ent, weaponframe))
pflags |= PF_WEAPONFRAME;
MSG_WriteByte (msg, svc_playerinfo);
MSG_WriteByte (msg, j);
@ -472,6 +500,36 @@ SV_WritePlayersToClient (client_t *client, edict_t *clent, byte * pvs,
if (pflags & PF_WEAPONFRAME)
MSG_WriteByte (msg, SVfloat (ent, weaponframe));
if (pflags & PF_QF) {
MSG_WriteByte (msg, qf_bits);
if (qf_bits & PF_ALPHA) {
float alpha = SVfloat (ent, alpha);
MSG_WriteByte (msg, bound (0, alpha, 1) * 255);
}
if (qf_bits & PF_SCALE) {
float scale = SVfloat (ent, scale);
MSG_WriteByte (msg, bound (0, scale, 15.9375) * 16);
}
if (qf_bits & PF_EFFECTS2) {
MSG_WriteByte (msg, (int) (SVfloat (ent, effects)) >> 8);
}
if (qf_bits & PF_GLOWSIZE) {
int glow_size = SVfloat (ent, scale);
MSG_WriteByte (msg, bound (-1024, glow_size, 1016) >> 3);
}
if (qf_bits & PF_GLOWCOLOR)
MSG_WriteByte (msg, SVfloat (ent, glow_color));
if (qf_bits & PF_COLORMOD) {
float *colormod= SVvector (ent, colormod);
MSG_WriteByte (msg,
((int) (bound (0, colormod[0], 1) * 7.0) << 5) |
((int) (bound (0, colormod[1], 1) * 7.0) << 2) |
(int) (bound (0, colormod[2], 1) * 3.0));
}
if (qf_bits & PF_FRAME2)
MSG_WriteByte (msg, (int) (SVfloat (ent, frame)) >> 8);
}
}
}