Skip to content

Commit

Permalink
Fixed|Multiplayer|All Games: Close automap and inventory when player …
Browse files Browse the repository at this point in the history
…dies

A new packet was added so the server can tell a particular client to
close their automap and inventory.

IssueID #2006
  • Loading branch information
skyjake committed May 9, 2015
1 parent 82cb619 commit 120d623
Show file tree
Hide file tree
Showing 10 changed files with 45 additions and 11 deletions.
3 changes: 2 additions & 1 deletion doomsday/plugins/common/include/d_net.h
Expand Up @@ -77,7 +77,8 @@ enum {
GPT_MAYBE_CHANGE_WEAPON, // Server suggests weapon change.
GPT_FINALE_STATE, // State of the InFine script.
GPT_LOCAL_MOBJ_STATE, // Set a state on a mobj and enable local actions.
GPT_TOTAL_COUNTS // Total kill, item, secret counts in the map.
GPT_TOTAL_COUNTS, // Total kill, item, secret counts in the map.
GPT_DISMISS_HUDS // Hide client's automap, inventory (added in 1.15)
};

#if 0
Expand Down
2 changes: 2 additions & 0 deletions doomsday/plugins/common/include/d_netcl.h
Expand Up @@ -45,6 +45,8 @@ void NetCl_UpdatePSpriteState(Reader *msg);
* Set the jump power used in client mode.
*/
void NetCl_UpdateJumpPower(Reader *msg);

void NetCl_DismissHUDs(Reader *msg);

void NetCl_Intermission(Reader *msg);

Expand Down
8 changes: 8 additions & 0 deletions doomsday/plugins/common/include/d_netsv.h
Expand Up @@ -76,6 +76,14 @@ void NetSv_TellCycleRulesToPlayerAfterTics(int destPlr, int tics);
*/
void NetSv_PlayerMobjImpulse(mobj_t *mobj, float mx, float my, float mz);

/**
* Forcibly dismisses HUDs (automap, inventory) of a particular player.
*
* @param player Player number.
* @param fast Quick dismiss.
*/
void NetSv_DismissHUDs(int player, dd_bool fast);

/**
* @param origin
* @param soundId
Expand Down
4 changes: 4 additions & 0 deletions doomsday/plugins/common/src/d_net.cpp
Expand Up @@ -632,6 +632,10 @@ void D_HandlePacket(int fromplayer, int type, void *data, size_t length)
NetCl_UpdateJumpPower(reader);
break;

case GPT_DISMISS_HUDS:
NetCl_DismissHUDs(reader);
break;

default:
App_Log(DE2_NET_WARNING, "Game received unknown packet (type:%i)", type);
}
Expand Down
6 changes: 6 additions & 0 deletions doomsday/plugins/common/src/d_netcl.cpp
Expand Up @@ -852,6 +852,12 @@ void NetCl_UpdateJumpPower(reader_s *msg)
App_Log(DE2_LOG_VERBOSE, "Jump power: %g", netJumpPower);
}

void NetCl_DismissHUDs(reader_s *msg)
{
dd_bool fast = Reader_ReadByte(msg)? true : false;
ST_CloseAll(CONSOLEPLAYER, fast);
}

void NetCl_FloorHitRequest(player_t *player)
{
writer_s *msg;
Expand Down
11 changes: 11 additions & 0 deletions doomsday/plugins/common/src/d_netsv.cpp
Expand Up @@ -736,6 +736,17 @@ void NetSv_PlayerMobjImpulse(mobj_t *mobj, float mx, float my, float mz)
Net_SendPacket(plrNum, GPT_MOBJ_IMPULSE, Writer_Data(writer), Writer_Size(writer));
}

void NetSv_DismissHUDs(int plrNum, dd_bool fast)
{
if(!IS_SERVER) return;
if(plrNum < 1 || plrNum >= DDMAXPLAYERS) return;

writer_s *writer = D_NetWrite();
Writer_WriteByte(writer, fast? 1 : 0);

Net_SendPacket(plrNum, GPT_DISMISS_HUDS, Writer_Data(writer), Writer_Size(writer));
}

void NetSv_SendPlayerSpawnPosition(int plrNum, float x, float y, float z, int angle)
{
if(!IS_SERVER) return;
Expand Down
6 changes: 3 additions & 3 deletions doomsday/plugins/doom/src/st_stuff.cpp
Expand Up @@ -34,6 +34,7 @@

#include "dmu_lib.h"
#include "d_net.h"
#include "d_netsv.h"
#include "hu_stuff.h"
#include "hu_lib.h"
#include "hu_chat.h"
Expand Down Expand Up @@ -3008,10 +3009,9 @@ void ST_Shutdown()

void ST_CloseAll(int player, dd_bool fast)
{
NetSv_DismissHUDs(player, fast);

ST_AutomapOpen(player, false, fast);
#if __JHERETIC__ || __JHEXEN__
Hu_InventoryOpen(player, false);
#endif
}

uiwidget_t *ST_UIChatForPlayer(int player)
Expand Down
6 changes: 3 additions & 3 deletions doomsday/plugins/doom64/src/st_stuff.c
Expand Up @@ -33,6 +33,7 @@

#include "dmu_lib.h"
#include "d_net.h"
#include "d_netsv.h"
#include "hu_stuff.h"
#include "hu_lib.h"
#include "hu_chat.h"
Expand Down Expand Up @@ -772,10 +773,9 @@ void ST_Shutdown(void)

void ST_CloseAll(int player, dd_bool fast)
{
NetSv_DismissHUDs(player, fast);

ST_AutomapOpen(player, false, fast);
#if __JHERETIC__ || __JHEXEN__
Hu_InventoryOpen(player, false);
#endif
}

uiwidget_t* ST_UIChatForPlayer(int player)
Expand Down
5 changes: 3 additions & 2 deletions doomsday/plugins/heretic/src/st_stuff.cpp
Expand Up @@ -34,6 +34,7 @@

#include "am_map.h"
#include "d_net.h"
#include "d_netsv.h"
#include "dmu_lib.h"
#include "hu_stuff.h"
#include "p_mapsetup.h"
Expand Down Expand Up @@ -2772,10 +2773,10 @@ void ST_Shutdown()

void ST_CloseAll(int player, dd_bool fast)
{
NetSv_DismissHUDs(player, fast);

ST_AutomapOpen(player, false, fast);
#if __JHERETIC__ || __JHEXEN__
Hu_InventoryOpen(player, false);
#endif
}

uiwidget_t *ST_UIChatForPlayer(int player)
Expand Down
5 changes: 3 additions & 2 deletions doomsday/plugins/hexen/src/st_stuff.cpp
Expand Up @@ -34,6 +34,7 @@
#include <cstring>

#include "d_net.h"
#include "d_netsv.h"
#include "dmu_lib.h"
#include "g_common.h"
#include "p_inventory.h"
Expand Down Expand Up @@ -3133,10 +3134,10 @@ void ST_Shutdown()

void ST_CloseAll(int player, dd_bool fast)
{
NetSv_DismissHUDs(player, fast);

ST_AutomapOpen(player, false, fast);
#if __JHERETIC__ || __JHEXEN__
Hu_InventoryOpen(player, false);
#endif
}

uiwidget_t *ST_UIChatForPlayer(int player)
Expand Down

0 comments on commit 120d623

Please sign in to comment.