Skip to content

Commit

Permalink
Fixed: Frags should be cleared for a newly joined player
Browse files Browse the repository at this point in the history
  • Loading branch information
skyjake committed Jul 18, 2011
1 parent 14e3050 commit 4a38f3a
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 2 deletions.
5 changes: 3 additions & 2 deletions doomsday/plugins/common/include/d_netsv.h
Expand Up @@ -44,8 +44,9 @@ extern char gameConfigString[];

void P_Telefrag(mobj_t *thing);

void NetSv_NewPlayerEnters(int plrnumber);
void *NetSv_ReadCommands(byte *msg, uint size);
void NetSv_NewPlayerEnters(int plrNum);
void NetSv_ResetPlayerFrags(int plrNum);
//void *NetSv_ReadCommands(byte *msg, uint size);
void NetSv_SendGameState(int flags, int to);
void NetSv_SendPlayerSpawnPosition(int plrNum, float x, float y, float z, int angle);
void NetSv_SendMessage(int plrNum, char *msg);
Expand Down
28 changes: 28 additions & 0 deletions doomsday/plugins/common/src/d_netsv.c
Expand Up @@ -755,6 +755,31 @@ void NetSv_MapCycleTicker(void)
}
}

/**
* Resets a player's frag count and other players' frag counts toward the player.
*
* @param plrNum Player to reset.
*/
void NetSv_ResetPlayerFrags(int plrNum)
{
int i;
player_t* plr = &players[plrNum];

#ifdef _DEBUG
Con_Message("NetSv_ResetPlayerFrags: Player %i.\n", plrNum);
#endif
memset(plr->frags, 0, sizeof(plr->frags));

// The frag count is dependent on the others' frags.
for(i = 0; i < MAXPLAYERS; ++i)
{
players[i].frags[plrNum] = 0;

// Everybody will get their frags updated.
players[i].update |= PSF_FRAGS;
}
}

/**
* Server calls this when new players enter the game.
*/
Expand All @@ -769,6 +794,9 @@ void NetSv_NewPlayerEnters(int plrNum)
// Re-deal player starts.
P_DealPlayerStarts(0);

// Reset the player's frags.
NetSv_ResetPlayerFrags(plrNum);

// Spawn the player into the world.
if(deathmatch)
{
Expand Down

0 comments on commit 4a38f3a

Please sign in to comment.