Skip to content

Commit

Permalink
add muted voice icon
Browse files Browse the repository at this point in the history
the buggy mute system is confusing
  • Loading branch information
wootguy committed Nov 11, 2024
1 parent 0810731 commit 26174ba
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 5 deletions.
2 changes: 1 addition & 1 deletion dlls/CWorld.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -118,12 +118,12 @@ void CWorld::Precache(void)
delete g_pGameRules;
}

g_pGameRules = InstallGameRules();
g_pluginManager.UpdatePluginsFromList();
if (pluginautoupdate.value) {
g_pluginManager.UpdatePlugins();
}
loadReplacementFiles();
g_pGameRules = InstallGameRules();

//!!!UNDONE why is there so much Spawn code in the Precache function? I'll just keep it here

Expand Down
22 changes: 20 additions & 2 deletions dlls/hooks/rehlds_hooks.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
#include "rehlds.h"
#include "util.h"
#include "PluginManager.h"
#include "cbase.h"
#include "CBasePlayer.h"

void rehlds_SendBigMessage_internal(int msgType, void* data, int sz, int playerindex) {
IGameClient* dstClient = g_RehldsSvs->GetClient(playerindex - 1);
Expand Down Expand Up @@ -48,20 +50,36 @@ void SV_ParseVoiceData_hlcoop(IGameClient* cl) {
if (sv_voiceenable->value == 0.0f)
return;

static float lastIconTime[33];

int sender = cl->GetId();
for (int i = 1; i <= gpGlobals->maxClients; i++)
{
CBasePlayer* plr = UTIL_PlayerByIndex(i);

if (!plr || !g_engfuncs.pfnVoice_GetClientListening(i, sender+1)) {
if (!plr) {
continue;
}

bool pluginWantsMute = false;

CALL_HOOKS_VOID(pfnSendVoiceData, sender + 1, i, chReceived, nDataLength, pluginWantsMute);

if (pluginWantsMute) {
if (!g_engfuncs.pfnVoice_GetClientListening(i, sender+1) || pluginWantsMute) {

// indicate that the player is muted
if (gpGlobals->time - lastIconTime[i] > 0.15f || lastIconTime[i] > gpGlobals->time) {
MESSAGE_BEGIN(MSG_ONE_UNRELIABLE, SVC_TEMPENTITY, NULL, plr->edict());
WRITE_BYTE(TE_PLAYERATTACHMENT);
WRITE_BYTE(sender + 1);
WRITE_COORD(45);
WRITE_SHORT(MODEL_INDEX(GET_MODEL("sprites/voiceicon_m.spr")));
WRITE_SHORT(2);
MESSAGE_END();

lastIconTime[i] = gpGlobals->time;
}

continue;
}

Expand Down
3 changes: 2 additions & 1 deletion game_shared/voice_gamemgr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,8 @@ bool CVoiceGameMgr::Init(
{
m_pHelper = pHelper;
m_nMaxPlayers = VOICE_MAX_PLAYERS < maxClients ? VOICE_MAX_PLAYERS : maxClients;
g_engfuncs.pfnPrecacheModel("sprites/voiceicon.spr");
PRECACHE_MODEL("sprites/voiceicon.spr");
PRECACHE_MODEL("sprites/voiceicon_m.spr");

m_msgPlayerVoiceMask = REG_USER_MSG( "VoiceMask", VOICE_MAX_PLAYERS_DW*4 * 2 );
m_msgRequestState = REG_USER_MSG( "ReqState", 0 );
Expand Down
2 changes: 1 addition & 1 deletion sevenkewp

0 comments on commit 26174ba

Please sign in to comment.