Skip to content

Commit

Permalink
Server: Keep clients' kill, item, and secret counters up to date
Browse files Browse the repository at this point in the history
Whenever a counter changes, an update is sent to the client.
  • Loading branch information
skyjake committed Mar 16, 2013
1 parent 0f92b24 commit 2015678
Show file tree
Hide file tree
Showing 12 changed files with 35 additions and 19 deletions.
9 changes: 7 additions & 2 deletions doomsday/plugins/common/src/d_netcl.c
Expand Up @@ -561,9 +561,14 @@ void NetCl_UpdatePlayerState(Reader *msg, int plrNum)

if(flags & PSF_COUNTERS)
{
pl->killCount = Reader_ReadInt16(msg);
pl->itemCount = Reader_ReadByte(msg);
pl->killCount = Reader_ReadInt16(msg);
pl->itemCount = Reader_ReadByte(msg);
pl->secretCount = Reader_ReadByte(msg);

#ifdef _DEBUG
Con_Message("NetCl_UpdatePlayerState: kills=%i, items=%i, secrets=%i",
pl->killCount, pl->itemCount, pl->secretCount);
#endif
}

if(flags & PSF_PENDING_WEAPON || flags & PSF_READY_WEAPON)
Expand Down
11 changes: 1 addition & 10 deletions doomsday/plugins/common/src/d_netsv.c
Expand Up @@ -190,20 +190,12 @@ void NetSv_Ticker(void)
{
player_t* plr = &players[i];

/*
// Don't send on every tic. Also, don't send to all
// players at the same time.
if(((int) GAMETIC + i) % 10)
continue;
*/

if(!plr->plr->inGame)
continue;

if(plr->update)
{
// Owned weapons and player state will be sent in a new kind of
// packet.
// Owned weapons and player state will be sent in the v2 packet.
if(plr->update & (PSF_OWNED_WEAPONS | PSF_STATE))
{
int flags =
Expand All @@ -218,7 +210,6 @@ void NetSv_Ticker(void)
continue;
}

// The delivery of the state packet will be confirmed.
NetSv_SendPlayerState(i, i, plr->update, true);
plr->update = 0;
}
Expand Down
3 changes: 1 addition & 2 deletions doomsday/plugins/common/src/g_game.c
Expand Up @@ -2469,8 +2469,7 @@ void G_DoMapCompleted(void)
G_PlayerLeaveMap(i); // take away cards and stuff

// Update this client's stats.
NetSv_SendPlayerState(i, DDSP_ALL_PLAYERS,
PSF_FRAGS | PSF_COUNTERS, true);
NetSv_SendPlayerState(i, DDSP_ALL_PLAYERS, PSF_FRAGS | PSF_COUNTERS, true);
}
}

Expand Down
1 change: 1 addition & 0 deletions doomsday/plugins/common/src/p_mapsetup.c
Expand Up @@ -851,6 +851,7 @@ static void P_ResetWorldState(void)

ddplr->mo = NULL;
plr->killCount = plr->secretCount = plr->itemCount = 0;
plr->update |= PSF_COUNTERS;

if(ddplr->inGame && plr->playerState == PST_DEAD)
plr->playerState = PST_REBORN;
Expand Down
6 changes: 6 additions & 0 deletions doomsday/plugins/doom/src/p_inter.c
Expand Up @@ -861,7 +861,10 @@ void P_TouchSpecialMobj(mobj_t* special, mobj_t* toucher)
}

if(special->flags & MF_COUNTITEM)
{
player->itemCount++;
player->update |= PSF_COUNTERS;
}

P_MobjRemove(special, false);

Expand Down Expand Up @@ -893,7 +896,10 @@ void P_KillMobj(mobj_t *source, mobj_t *target, boolean stomping)
{
// Count for intermission.
if(target->flags & MF_COUNTKILL)
{
source->player->killCount++;
source->player->update |= PSF_COUNTERS;
}

if(target->player)
{
Expand Down
3 changes: 2 additions & 1 deletion doomsday/plugins/doom/src/p_spec.c
Expand Up @@ -51,7 +51,7 @@
#include "p_plat.h"
#include "p_scroll.h"
#include "p_switch.h"
#include "d_netsv.h"
#include "d_net.h"

// MACROS ------------------------------------------------------------------

Expand Down Expand Up @@ -822,6 +822,7 @@ void P_PlayerInSpecialSector(player_t* player)

case 9: ///< SECRET SECTOR
player->secretCount++;
player->update |= PSF_COUNTERS;
P_ToXSector(sector)->special = 0;
if(cfg.secretMsg)
{
Expand Down
6 changes: 6 additions & 0 deletions doomsday/plugins/doom64/src/p_inter.c
Expand Up @@ -882,7 +882,10 @@ void P_TouchSpecialMobj(mobj_t* special, mobj_t* toucher)
}

if(special->flags & MF_COUNTITEM)
{
player->itemCount++;
player->update |= PSF_COUNTERS;
}

P_MobjRemove(special, false);
player->bonusCount += BONUSADD;
Expand Down Expand Up @@ -913,7 +916,10 @@ void P_KillMobj(mobj_t *source, mobj_t *target, boolean stomping)
{
// Count for intermission.
if(target->flags & MF_COUNTKILL)
{
source->player->killCount++;
source->player->update |= PSF_COUNTERS;
}

if(target->player)
{
Expand Down
3 changes: 2 additions & 1 deletion doomsday/plugins/doom64/src/p_spec.c
Expand Up @@ -55,7 +55,7 @@
#include "p_plat.h"
#include "p_scroll.h"
#include "p_switch.h"
#include "d_netsv.h"
#include "d_net.h"

// MACROS ------------------------------------------------------------------

Expand Down Expand Up @@ -491,6 +491,7 @@ static void P_CrossSpecialLine(LineDef* line, int side, mobj_t* thing)
/// Also, export this text string to DED.
P_SetMessage(thing->player, 0, "You've found a secret area!");
thing->player->secretCount++;
thing->player->update |= PSF_COUNTERS;
xline->special = 0;
break;

Expand Down
1 change: 0 additions & 1 deletion doomsday/plugins/heretic/src/in_lude.c
Expand Up @@ -913,7 +913,6 @@ void IN_DrawCoopStats(void)
DGL_Color4f(defFontRGB[0], defFontRGB[1], defFontRGB[2], 1);
GL_DrawPatchXY(dpFaceAlive[i], 25, ypos);


if(interTime < 40)
{
sounds = 0;
Expand Down
7 changes: 6 additions & 1 deletion doomsday/plugins/heretic/src/p_inter.c
Expand Up @@ -860,7 +860,10 @@ void P_TouchSpecialMobj(mobj_t* special, mobj_t* toucher)
}

if(special->flags & MF_COUNTITEM)
{
player->itemCount++;
player->update |= PSF_COUNTERS;
}

switch(item)
{
Expand Down Expand Up @@ -904,8 +907,10 @@ void P_KillMobj(mobj_t* source, mobj_t* target)
if(source && source->player)
{
if(target->flags & MF_COUNTKILL)
{ // Count for intermission.
{
// Count for intermission.
source->player->killCount++;
source->player->update |= PSF_COUNTERS;
}

if(target->player)
Expand Down
3 changes: 2 additions & 1 deletion doomsday/plugins/heretic/src/p_spec.c
Expand Up @@ -54,7 +54,7 @@
#include "p_user.h"
#include "p_scroll.h"
#include "p_switch.h"
#include "d_netsv.h"
#include "d_net.h"

// MACROS ------------------------------------------------------------------

Expand Down Expand Up @@ -864,6 +864,7 @@ void P_PlayerInSpecialSector(player_t* player)
{
// SECRET SECTOR
player->secretCount++;
player->update |= PSF_COUNTERS;
P_ToXSector(sector)->special = 0;
if(cfg.secretMsg)
{
Expand Down
1 change: 1 addition & 0 deletions doomsday/plugins/hexen/src/p_spec.c
Expand Up @@ -676,6 +676,7 @@ void P_PlayerInSpecialSector(player_t* player)
if(!IS_CLIENT)
{
player->secretCount++;
player->update |= PSF_COUNTERS;
xsector->special = 0;
}
break;
Expand Down

0 comments on commit 2015678

Please sign in to comment.