player deltas seem to be working

This commit is contained in:
Bill Currie 2005-05-09 12:12:48 +00:00
parent 85c25488b1
commit 47bf8c8423
4 changed files with 77 additions and 43 deletions

View file

@ -440,65 +440,89 @@ sv_packetentities (server_t *sv, qmsg_t *msg, int delta)
}
static void
sv_playerinfo (server_t *sv, qmsg_t *msg)
parse_player_delta (qmsg_t *msg, plent_state_t *to)
{
player_t *pl;
plent_state_t dummy; // for bad player indices
plent_state_t *ent;
int num, flags;
int i;
int flags;
num = MSG_ReadByte (msg);
if (num > MAX_SV_PLAYERS) {
qtv_printf ("bogus player: %d\n", num);
ent = &dummy;
} else {
pl = &sv->players[num];
ent = &pl->ent;
}
flags = ent->flags = MSG_ReadShort (msg);
//qtv_printf ("%2d %x\n", num, flags);
MSG_ReadCoordV (msg, ent->origin);
ent->frame = (ent->frame & 0xff00) | MSG_ReadByte (msg);
flags = to->flags = MSG_ReadShort (msg);
MSG_ReadCoordV (msg, to->origin);
to->frame = (to->frame & 0xff00) | MSG_ReadByte (msg);
if (flags & PF_MSEC)
ent->msec = MSG_ReadByte (msg);
to->msec = MSG_ReadByte (msg);
if (flags & PF_COMMAND)
MSG_ReadDeltaUsercmd (msg, &nullcmd, &ent->cmd);
MSG_ReadDeltaUsercmd (msg, &nullcmd, &to->cmd);
for (i = 0; i < 3; i++) {
if (flags & (PF_VELOCITY1 << i))
ent->velocity[i] = MSG_ReadShort (msg);
to->velocity[i] = MSG_ReadShort (msg);
}
if (flags & PF_MODEL)
ent->modelindex = MSG_ReadByte (msg);
to->modelindex = MSG_ReadByte (msg);
if (flags & PF_SKINNUM)
ent->skinnum = MSG_ReadByte (msg);
to->skinnum = MSG_ReadByte (msg);
if (flags & PF_EFFECTS)
ent->effects = (ent->effects & 0xff00) | MSG_ReadByte (msg);;
to->effects = (to->effects & 0xff00) | MSG_ReadByte (msg);;
if (flags & PF_WEAPONFRAME)
ent->weaponframe = MSG_ReadByte (msg);
to->weaponframe = MSG_ReadByte (msg);
if (flags & PF_QF) {
int bits;
bits = MSG_ReadByte (msg);
if (bits & PF_ALPHA)
ent->alpha = MSG_ReadByte (msg);
to->alpha = MSG_ReadByte (msg);
if (bits & PF_SCALE)
ent->scale = MSG_ReadByte (msg);
to->scale = MSG_ReadByte (msg);
if (bits & PF_EFFECTS2)
ent->effects = (ent->effects & 0x00ff)
| (MSG_ReadByte (msg) << 8);
to->effects = (to->effects & 0x00ff)
| (MSG_ReadByte (msg) << 8);
if (bits & PF_GLOWSIZE)
ent->glow_size = MSG_ReadByte (msg);
to->glow_size = MSG_ReadByte (msg);
if (bits & PF_GLOWCOLOR)
ent->glow_color = MSG_ReadByte (msg);
to->glow_color = MSG_ReadByte (msg);
if (bits & PF_COLORMOD)
ent->colormod = MSG_ReadByte (msg);
to->colormod = MSG_ReadByte (msg);
if (bits & PF_FRAME2)
ent->frame = (ent->frame & 0xff)
| (MSG_ReadByte (msg) << 8);
to->frame = (to->frame & 0xff)
| (MSG_ReadByte (msg) << 8);
}
}
static void
sv_playerinfo (server_t *sv, qmsg_t *msg)
{
plent_state_t dummy; // for bad player indices
plent_state_t *ent;
plent_state_t *from, *to;
int num;
int fromind, toind;
static plent_state_t null_player_state;
if (!null_player_state.alpha) {
null_player_state.alpha = 255;
null_player_state.scale = 16;
null_player_state.glow_size = 0;
null_player_state.glow_color = 254;
null_player_state.colormod = 255;
}
fromind = MSG_ReadByte (msg);
toind = sv->netchan.incoming_sequence & UPDATE_MASK;
num = MSG_ReadByte (msg);
if (num > MAX_SV_PLAYERS) {
qtv_printf ("bogus player: %d\n", num);
ent = from = to = &dummy;
} else {
ent = &sv->players[num].ent;
from = &null_player_state;
if (fromind != 255)
from = &sv->player_states[fromind & UPDATE_MASK][num];
to = &sv->player_states[toind][num];
*to = *from;
}
parse_player_delta (msg, to);
qtv_printf ("%3d %g %g %g %d\n", fromind, to->origin[0], to->origin[1], to->origin[2], to->modelindex);
*ent = *to;
}
static void
sv_serverinfo (server_t *sv, qmsg_t *msg)
{

View file

@ -139,6 +139,7 @@ typedef struct {
typedef enum {
dt_tp_normal,
dt_tp_demo,
dt_tp_qtv,
} delta_type_t;
typedef enum {

View file

@ -396,8 +396,8 @@ SV_EmitPacketEntities (delta_t *delta, packet_entities_t *to, sizebuf_t *msg,
}
static void
write_demoplayer (plent_state_t *from, plent_state_t *to, sizebuf_t *msg,
int mask, int full)
write_demoplayer (delta_t *delta, plent_state_t *from, plent_state_t *to,
sizebuf_t *msg, int mask, int full)
{
int flags;
int j;
@ -455,12 +455,13 @@ write_demoplayer (plent_state_t *from, plent_state_t *to, sizebuf_t *msg,
}
static void
write_player (plent_state_t *from, plent_state_t *to, sizebuf_t *msg, int mask,
int full)
write_player (delta_t *delta, plent_state_t *from, plent_state_t *to,
sizebuf_t *msg, int mask, int full)
{
int flags = to->flags;
int qf_bits = 0;
int i;
int ds = delta->delta_sequence & 0x7f;
if (full) {
flags |= PF_VELOCITY1 | PF_VELOCITY2 | PF_VELOCITY3 | PF_MODEL
@ -470,6 +471,7 @@ write_player (plent_state_t *from, plent_state_t *to, sizebuf_t *msg, int mask,
| PF_GLOWCOLOR | PF_COLORMOD | PF_FRAME2;
flags |= PF_QF;
}
ds = -1;
} else {
for (i = 0; i < 3; i++)
if (from->velocity[i] != to->velocity[i])
@ -504,6 +506,8 @@ write_player (plent_state_t *from, plent_state_t *to, sizebuf_t *msg, int mask,
flags &= mask;
MSG_WriteByte (msg, svc_playerinfo);
if (delta->type == dt_tp_qtv)
MSG_WriteByte (msg, ds);
MSG_WriteByte (msg, to->number);
MSG_WriteShort (msg, flags);
@ -560,7 +564,8 @@ SV_WritePlayersToClient (delta_t *delta, byte *pvs, sizebuf_t *msg)
packet_players_t *from_pack = 0;
plent_state_t dummy_player_state, *state = &dummy_player_state;
static plent_state_t null_player_state;
void (*write) (plent_state_t *, plent_state_t *, sizebuf_t *, int, int);
void (*write) (delta_t *, plent_state_t *, plent_state_t *, sizebuf_t *,
int, int);
if (!null_player_state.alpha) {
null_player_state.alpha = 255;
@ -586,7 +591,7 @@ SV_WritePlayersToClient (delta_t *delta, byte *pvs, sizebuf_t *msg)
if (delta->delta_sequence != -1) {
client_frame_t *fromframe;
fromframe = &delta->frames[delta->delta_sequence & UPDATE_MASK];
from_pack = &frame->players;
from_pack = &fromframe->players;
full = 0;
}
@ -689,14 +694,17 @@ SV_WritePlayersToClient (delta_t *delta, byte *pvs, sizebuf_t *msg)
mask |= PF_WEAPONFRAME;
if (from_pack && from_pack->players) {
while (from_pack->players[k].number < state->number)
while (k < from_pack->num_players
&& from_pack->players[k].number < state->number)
k++;
if (from_pack->players[k].number == state->number) {
write (&from_pack->players[k], state, msg, mask, full);
if (k < from_pack->num_players
&& from_pack->players[k].number == state->number) {
write (delta, &from_pack->players[k], state, msg, mask, full);
continue;
}
full = 1;
}
write (&null_player_state, state, msg, mask, full);
write (delta, &null_player_state, state, msg, mask, full);
}
}

View file

@ -351,6 +351,7 @@ SVR_AddUser (void (*write)(void *, sizebuf_t *, int), int (*frame)(void *),
r->next = sv.recorders;
sv.recorders = r;
r->delta.type = dt_tp_qtv;
r->delta.pvs = dt_pvs_none;
if (demo) {
r->delta.type = dt_tp_demo;