Skip to content

Commit

Permalink
Fixing player respawning in a netgame
Browse files Browse the repository at this point in the history
Previously the server completely failed to respawn a dead
player. Now the respawning occurs successfully, and the client
reappears and telefrags at the correct place. However, the client
currently is unable to move after respawning, probably due
to some mixup with the player mobj/clmobj.
  • Loading branch information
skyjake committed Mar 23, 2011
1 parent 4385d22 commit 36dbc2a
Show file tree
Hide file tree
Showing 5 changed files with 62 additions and 22 deletions.
2 changes: 1 addition & 1 deletion doomsday/engine/portable/include/net_main.h
Expand Up @@ -83,7 +83,7 @@ enum {
PSV_CONSOLE_TEXT = 11,
PCL_ACK_SHAKE = 12,
PSV_SYNC = 13,
PSV_FILTER = 14, // unused?
//PSV_FILTER = 14, // unused?
PKT_COMMAND = 15, // obsolete
PKT_LOGIN = 16,
PCL_ACK_SETS = 17,
Expand Down
4 changes: 3 additions & 1 deletion doomsday/engine/portable/src/cl_main.c
Expand Up @@ -284,6 +284,7 @@ void Cl_GetPackets(void)
Cl_Sound();
break;

/*
case PSV_FILTER:
{
player_t* plr = &ddPlayers[consolePlayer];
Expand All @@ -299,7 +300,8 @@ void Cl_GetPackets(void)
plr->shared.filterColor[CB] = (filter >> 16) & 0xff;
plr->shared.filterColor[CA] = (filter >> 24) & 0xff;
break;
}
}*/

default:
handled = false;
}
Expand Down
10 changes: 9 additions & 1 deletion doomsday/engine/portable/src/cl_player.c
Expand Up @@ -237,7 +237,7 @@ Con_Message("Cl_RPlD: pl=%i => moid=%i\n", num, s->mobjId);
}
if(df & PDF_FILTER)
{
int filter = Msg_ReadLong();
int filter = Msg_ReadLong();

if(filter)
ddpl->flags |= DDPF_VIEW_FILTER;
Expand All @@ -248,6 +248,14 @@ Con_Message("Cl_RPlD: pl=%i => moid=%i\n", num, s->mobjId);
ddpl->filterColor[CG] = (filter >> 8) & 0xff;
ddpl->filterColor[CB] = (filter >> 16) & 0xff;
ddpl->filterColor[CA] = (filter >> 24) & 0xff;

#ifdef _DEBUG
Con_Message("PDF_FILTER: Filter color set to (%f,%f,%f,%f)\n",
ddpl->filterColor[CR],
ddpl->filterColor[CG],
ddpl->filterColor[CB],
ddpl->filterColor[CA]);
#endif
}
if(df & PDF_CLYAW) // Only sent when Fixangles is used.
//pl->clAngle = Msg_ReadShort() << 16; /* $unifiedangles */
Expand Down
18 changes: 11 additions & 7 deletions doomsday/plugins/common/src/g_game.c
Expand Up @@ -792,11 +792,9 @@ void G_ChangeGameState(gamestate_t state)
if(gameState != state)
{
#if _DEBUG
// Log gamestate changes in debug builds, with verbose.
VERBOSE(Con_Message("G_ChangeGameState: New state %s.\n",
getGameStateStr(state)));
// Log gamestate changes in debug builds, with verbose.
Con_Message("G_ChangeGameState: New state %s.\n", getGameStateStr(state));
#endif

gameState = state;
}

Expand Down Expand Up @@ -1254,7 +1252,7 @@ void G_Ticker(timespan_t ticLength)

// Let's get rid of the mobj.
#ifdef _DEBUG
Con_Message("G_Ticker: Removing player %i's mobj.\n", i);
Con_Message("G_Ticker: Removing player %i's mobj.\n", i);
#endif
P_MobjRemove(plr->plr->mo, true);
plr->plr->mo = NULL;
Expand Down Expand Up @@ -1643,8 +1641,14 @@ void G_DoReborn(int plrNum)
if(plrNum < 0 || plrNum >= MAXPLAYERS)
return; // Wha?

// Clear the currently playing script, if any.
FI_Reset();
if(plrNum == CONSOLEPLAYER)
{
#ifdef _DEBUG
Con_Message("G_DoReborn: Console player reborn, reseting InFine.\n");
#endif
// Clear the currently playing script, if any.
FI_Reset();
}

if(!IS_NETGAME)
{
Expand Down
50 changes: 38 additions & 12 deletions doomsday/plugins/common/src/p_start.c
Expand Up @@ -406,6 +406,11 @@ void P_SpawnPlayer(int plrNum, playerclass_t pClass, float x, float y,
"(class:%i) pos:[%g, %g, %g] angle:%i.", plrNum, pClass,
x, y, z, angle);

#ifdef _DEBUG
Con_Message("P_SpawnPlayer: player %i spawned at (%f,%f,%f) floorz=%f\n",
plrNum, mo->pos[VX], mo->pos[VY], mo->pos[VZ], mo->floorZ);
#endif

p = &players[plrNum];
if(p->playerState == PST_REBORN)
G_PlayerReborn(plrNum);
Expand Down Expand Up @@ -611,17 +616,17 @@ void P_RebornPlayer(int plrNum)
#else
playerclass_t pClass = PCLASS_PLAYER;
#endif
float pos[3];
angle_t angle;
int spawnFlags;
boolean makeCamera;
float pos[3] = { 0, 0, 0 };
angle_t angle = 0;
int spawnFlags = 0;
boolean makeCamera = false;

if(plrNum < 0 || plrNum >= MAXPLAYERS)
return; // Wha?

p = &players[plrNum];

Con_Printf("P_RebornPlayer: %i.\n", plrNum);
Con_Message("P_RebornPlayer: %i.\n", plrNum);

if(p->plr->mo)
{
Expand All @@ -631,7 +636,12 @@ void P_RebornPlayer(int plrNum)
}

if(G_GetGameState() != GS_MAP)
{
#ifdef _DEBUG
Con_Message("P_RebornPlayer: Game state is %i, won't spawn.\n", G_GetGameState());
#endif
return; // Nothing else to do.
}

// Spawn at random spot if in death match.
if(deathmatch)
Expand Down Expand Up @@ -673,13 +683,13 @@ void P_RebornPlayer(int plrNum)
#else
uint entryPoint = 0;
#endif
boolean foundSpot = false;
const playerstart_t* assigned =
P_GetPlayerStart(entryPoint, plrNum, false);
boolean foundSpot = false;
const playerstart_t* assigned = P_GetPlayerStart(entryPoint, plrNum, false);

if(assigned && P_CheckSpot(assigned->pos[VX], assigned->pos[VY]))
{ // Appropriate player start spot is open.
Con_Printf("- spawning at assigned spot\n");
{
// Appropriate player start spot is open.
Con_Message("- spawning at assigned spot\n");

pos[VX] = assigned->pos[VX];
pos[VY] = assigned->pos[VY];
Expand All @@ -692,7 +702,7 @@ void P_RebornPlayer(int plrNum)
#if __JDOOM__ || __JHERETIC__ || __JDOOM64__
else
{
Con_Printf("- force spawning at %i.\n", p->startSpot);
Con_Message("- force spawning at %i.\n", p->startSpot);

if(assigned)
{
Expand Down Expand Up @@ -720,6 +730,10 @@ void P_RebornPlayer(int plrNum)
{
int i;

#ifdef _DEBUG
Con_Message("P_RebornPlayer: Trying other spots for %i.\n", plrNum);
#endif

// Try to spawn at one of the other player start spots.
for(i = 0; i < MAXPLAYERS; ++i)
{
Expand All @@ -737,14 +751,22 @@ void P_RebornPlayer(int plrNum)
spawnFlags = start->spawnFlags;

foundSpot = true;

#ifdef _DEBUG
Con_Message("P_RebornPlayer: Spot (%f,%f) selected.\n", start->pos[VX], start->pos[VY]);
#endif
break;
}
#ifdef _DEBUG
Con_Message("P_RebornPlayer: Spot (%f,%f) is not available.\n", start->pos[VX], start->pos[VY]);
#endif
}
}
}

if(!foundSpot)
{ // Player's going to be inside something.
{
// Player's going to be inside something.
const playerstart_t* start;

if((start = P_GetPlayerStart(rebornPosition, plrNum, false)))
Expand All @@ -766,6 +788,10 @@ void P_RebornPlayer(int plrNum)
#endif
}

#ifdef _DEBUG
Con_Message("P_RebornPlayer: Spawning player at (%f,%f,%f).\n", pos[VX], pos[VY], pos[VZ]);
#endif

spawnPlayer(plrNum, pClass, pos[VX], pos[VY], pos[VZ], angle,
spawnFlags, makeCamera, true, true);

Expand Down

0 comments on commit 36dbc2a

Please sign in to comment.