Skip to content

Commit

Permalink
Client: Adjusted the way fixes are acknowledged
Browse files Browse the repository at this point in the history
Now the ack is sent only after the new coordinates, momentum
and/or angles have been applied to the mobj.

Also added some debug messages when investigating the
cause for a spurious EV_Teleport call.
  • Loading branch information
skyjake committed Jul 21, 2011
1 parent 96ffee7 commit 87d22bb
Show file tree
Hide file tree
Showing 5 changed files with 45 additions and 20 deletions.
30 changes: 20 additions & 10 deletions doomsday/engine/portable/src/cl_player.c
Expand Up @@ -175,6 +175,7 @@ void ClPlayer_ApplyPendingFixes(int plrNum)
mobj_t *clmo = ClPlayer_ClMobj(plrNum);
ddplayer_t *ddpl = &plr->shared;
mobj_t *mo = ddpl->mo;
bool sendAck = false;

// If either mobj is missing, the fix cannot be applied yet.
if(!mo || !clmo) return;
Expand All @@ -187,6 +188,8 @@ void ClPlayer_ApplyPendingFixes(int plrNum)
if(state->pendingFixes & DDPF_FIXANGLES)
{
state->pendingFixes &= ~DDPF_FIXANGLES;
ddpl->fixAcked.angles = ddpl->fixCounter.angles;
sendAck = true;

#ifdef _DEBUG
Con_Message("ClPlayer_ApplyPendingFixes: Applying angle %x to mobj %p and clmo %i...\n",
Expand All @@ -199,6 +202,8 @@ void ClPlayer_ApplyPendingFixes(int plrNum)
if(state->pendingFixes & DDPF_FIXPOS)
{
state->pendingFixes &= ~DDPF_FIXPOS;
ddpl->fixAcked.pos = ddpl->fixCounter.pos;
sendAck = true;

#ifdef _DEBUG
Con_Message("ClPlayer_ApplyPendingFixes: Applying pos (%f, %f, %f) to mobj %p and clmo %i...\n",
Expand All @@ -217,6 +222,8 @@ void ClPlayer_ApplyPendingFixes(int plrNum)
if(state->pendingFixes & DDPF_FIXMOM)
{
state->pendingFixes &= ~DDPF_FIXMOM;
ddpl->fixAcked.mom = ddpl->fixCounter.mom;
sendAck = true;

#ifdef _DEBUG
Con_Message("ClPlayer_ApplyPendingFixes: Applying mom (%f, %f, %f) to mobj %p and clmo %i...\n",
Expand All @@ -227,6 +234,16 @@ void ClPlayer_ApplyPendingFixes(int plrNum)
mo->mom[MY] = clmo->mom[VY] = state->pendingMomFix[VY];
mo->mom[MZ] = clmo->mom[VZ] = state->pendingMomFix[VZ];
}

if(sendAck)
{
// Send an acknowledgement.
Msg_Begin(PCL_ACK_PLAYER_FIX);
Msg_WriteLong(ddpl->fixAcked.angles);
Msg_WriteLong(ddpl->fixAcked.pos);
Msg_WriteLong(ddpl->fixAcked.mom);
Net_SendBuffer(0, SPF_ORDERED | SPF_CONFIRM);
}
}

void ClPlayer_HandleFix(void)
Expand All @@ -242,7 +259,7 @@ void ClPlayer_HandleFix(void)

if(fixes & 1) // fix angles?
{
ddpl->fixCounter.angles = ddpl->fixAcked.angles = Msg_ReadLong();
ddpl->fixCounter.angles = Msg_ReadLong();
state->pendingAngleFix = Msg_ReadLong();
state->pendingLookDirFix = FIX2FLT(Msg_ReadLong());
state->pendingFixes |= DDPF_FIXANGLES;
Expand All @@ -255,7 +272,7 @@ void ClPlayer_HandleFix(void)

if(fixes & 2) // fix pos?
{
ddpl->fixCounter.pos = ddpl->fixAcked.pos = Msg_ReadLong();
ddpl->fixCounter.pos = Msg_ReadLong();
state->pendingPosFix[VX] = FIX2FLT(Msg_ReadLong());
state->pendingPosFix[VY] = FIX2FLT(Msg_ReadLong());
state->pendingPosFix[VZ] = FIX2FLT(Msg_ReadLong());
Expand All @@ -269,21 +286,14 @@ void ClPlayer_HandleFix(void)

if(fixes & 4) // fix momentum?
{
ddpl->fixCounter.mom = ddpl->fixAcked.mom = Msg_ReadLong();
ddpl->fixCounter.mom = Msg_ReadLong();
state->pendingMomFix[VX] = FIX2FLT(Msg_ReadLong());
state->pendingMomFix[VY] = FIX2FLT(Msg_ReadLong());
state->pendingMomFix[VZ] = FIX2FLT(Msg_ReadLong());
state->pendingFixes |= DDPF_FIXMOM;
}

ClPlayer_ApplyPendingFixes(consolePlayer);

// Send an acknowledgement.
Msg_Begin(PCL_ACK_PLAYER_FIX);
Msg_WriteLong(ddpl->fixAcked.angles);
Msg_WriteLong(ddpl->fixAcked.pos);
Msg_WriteLong(ddpl->fixAcked.mom);
Net_SendBuffer(0, SPF_ORDERED | SPF_CONFIRM);
}

/**
Expand Down
19 changes: 11 additions & 8 deletions doomsday/engine/portable/src/sv_main.c
Expand Up @@ -693,14 +693,14 @@ void Sv_GetPackets(void)
acked->pos = Msg_ReadLong();
acked->mom = Msg_ReadLong();
#ifdef _DEBUG
Con_Message("PCL_ACK_PLAYER_FIX: (%i) Angles %i (%i), pos %i (%i), mom %i (%i).\n",
netBuffer.player,
acked->angles,
ddpl->fixCounter.angles,
acked->pos,
ddpl->fixCounter.pos,
acked->mom,
ddpl->fixCounter.mom);
Con_Message("PCL_ACK_PLAYER_FIX: (%i) Angles %i (%i), pos %i (%i), mom %i (%i).\n",
netBuffer.player,
acked->angles,
ddpl->fixCounter.angles,
acked->pos,
ddpl->fixCounter.pos,
acked->mom,
ddpl->fixCounter.mom);
#endif
break;
}
Expand Down Expand Up @@ -1067,6 +1067,9 @@ Con_Message("Sv_SendPlayerFixes: Sent momentum (%i): %f, %f, %f\n",
Net_SendBuffer(plrNum, SPF_ORDERED | SPF_CONFIRM);

ddpl->flags &= ~(DDPF_FIXANGLES | DDPF_FIXPOS | DDPF_FIXMOM);
#ifdef _DEBUG
Con_Message("Sv_SendPlayerFixes: Cleared FIX flags of player %i.\n", plrNum);
#endif
}

void Sv_Ticker(void)
Expand Down
3 changes: 1 addition & 2 deletions doomsday/engine/portable/src/sys_network.c
Expand Up @@ -1231,8 +1231,7 @@ boolean N_LookForHosts(const char *address, int port)
sock = SDLNet_TCP_Open(&located.addr);
if(!sock)
{
Con_Message("N_LookForHosts: No reply from %s (port %i).\n", address,
port);
Con_Message("N_LookForHosts: No reply from %s (port %i).\n", address, port);
return false;
}

Expand Down
9 changes: 9 additions & 0 deletions doomsday/plugins/common/src/p_map.c
Expand Up @@ -1505,6 +1505,15 @@ static boolean P_TryMove2(mobj_t* thing, float x, float y, boolean dropoff)
P_ActivateLine(ld, thing, oldSide, SPAC_PCROSS);
}
#else
#ifdef _DEBUG
if(!IS_CLIENT && thing->player)
{
Con_Message("P_TryMove2: Mobj %i crossing line %i from %f,%f to %f,%f\n",
thing->thinker.id, P_ToIndex(ld),
oldpos[VX], oldpos[VY],
thing->pos[VX], thing->pos[VY]);
}
#endif
P_ActivateLine(ld, thing, oldSide, SPAC_CROSS);
#endif
}
Expand Down
4 changes: 4 additions & 0 deletions doomsday/plugins/jdoom/src/p_telept.c
Expand Up @@ -208,6 +208,10 @@ int EV_Teleport(linedef_t* line, int side, mobj_t* mo, boolean spawnFog)
//mo->dPlayer->clAngle = mo->angle; /* $unifiedangles */
mo->dPlayer->flags |=
DDPF_FIXANGLES | DDPF_FIXPOS | DDPF_FIXMOM;

#ifdef _DEBUG
Con_Message("EV_Teleport: Player %p set FIX flags.\n", mo->dPlayer);
#endif
}

return 1;
Expand Down

0 comments on commit 87d22bb

Please sign in to comment.