diff --git a/src/d_clisrv.c b/src/d_clisrv.c index d85f824ba..905a5bb74 100644 --- a/src/d_clisrv.c +++ b/src/d_clisrv.c @@ -90,9 +90,12 @@ char motd[254], server_context[8]; // Message of the Day, Unique Context (even w plrinfo playerinfo[MAXPLAYERS]; SINT8 joinnode = 0; // used for CL_VIEWSERVER +boolean player_muted[MAXPLAYERS] = {0}; + // Server specific vars UINT8 playernode[MAXPLAYERS]; + // Minimum timeout for sending the savegame // The actual timeout will be longer depending on the savegame length tic_t jointimeout = (3*TICRATE); @@ -3488,6 +3491,8 @@ void CL_Reset(void) #endif G_ResetAllDeviceRumbles(); + memset(player_muted, 0, sizeof(player_muted)); + // D_StartTitle should get done now, but the calling function will handle it } diff --git a/src/d_clisrv.h b/src/d_clisrv.h index 7ba47cfd6..bf5005e64 100644 --- a/src/d_clisrv.h +++ b/src/d_clisrv.h @@ -671,6 +671,8 @@ SINT8 nametonum(const char *name); extern char motd[254], server_context[8]; extern UINT8 playernode[MAXPLAYERS]; +extern boolean player_muted[MAXPLAYERS]; + INT32 D_NumPlayers(void); void D_ResetTiccmds(void); diff --git a/src/hu_stuff.c b/src/hu_stuff.c index 1ea07a9cf..07ebdd26f 100644 --- a/src/hu_stuff.c +++ b/src/hu_stuff.c @@ -949,6 +949,9 @@ static void Got_Saycmd(UINT8 **p, INT32 playernum) else stop_spamming[playernum] = 4; // you can hold off for 4 tics, can you? + if (player_muted[playernum]) + spam_eatmsg = 1; // Let lua know we're skipping this message + // run the lua hook even if we were supposed to eat the msg, netgame consistency goes first. if (LUA_HookPlayerMsg(playernum, target, flags, msg, spam_eatmsg)) @@ -1179,6 +1182,23 @@ static boolean HU_clearChatSpaces(void) return nothingbutspaces; } +static void DoMute(const char *name) +{ + INT32 pnum = D_LookupPlayer(name); + + if (pnum < 0) + { + HU_AddChatText("\x85""ERROR: \x80Player not found.", false); + return; + } + + player_muted[pnum] = !player_muted[pnum]; + + HU_AddChatText(va("Player '%s' has been %smuted.", player_names[pnum], player_muted[pnum] ? "" : "un"), false); + if (player_muted[pnum]) + HU_AddChatText("Use same command to unmute them.", false); +} + static void HU_SendChatMessage(void) { char buf[2 + HU_MAXMSGLEN + 1]; @@ -1205,7 +1225,19 @@ static void HU_SendChatMessage(void) return; } - if (strlen(msg) > 4 && strnicmp(msg, "/pm", 3) == 0) // used /pm + size_t len = strlen(msg); + + if (len >= 5 && strnicmp(msg, "/mute", 5) == 0) // Used /mute + { + if (len > 6) + DoMute(msg+6); + else + HU_AddChatText("\x82NOTICE: \x80Usage: /mute ", false); + + return; + } + + if (len > 4 && strnicmp(msg, "/pm", 3) == 0) // used /pm { INT32 spc = 1; // used if nodenum[1] is a space. char *nodenum = (char*) malloc(3);