diff --git a/gradle.properties b/gradle.properties index 9c1255b4..b08fc23c 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,3 +1,3 @@ majorVersion=5 -minorVersion=12 +minorVersion=13 maintenanceVersion=0 diff --git a/regamedll/dlls/gamerules.h b/regamedll/dlls/gamerules.h index dd17b8f9..80894003 100644 --- a/regamedll/dlls/gamerules.h +++ b/regamedll/dlls/gamerules.h @@ -806,9 +806,20 @@ class CCStrikeGameMgrHelper: public IVoiceGameMgrHelper public: virtual bool CanPlayerHearPlayer(CBasePlayer *pListener, CBasePlayer *pSender); +#ifdef REGAMEDLL_ADD + virtual void ResetCanHearPlayer(edict_t* pEdict); + virtual void SetCanHearPlayer(CBasePlayer* pListener, CBasePlayer* pSender, bool bCanHear); + virtual bool GetCanHearPlayer(CBasePlayer* pListener, CBasePlayer* pSender); +#endif + #ifdef REGAMEDLL_API bool CanPlayerHearPlayer_OrigFunc(CBasePlayer *pListener, CBasePlayer *pSender); #endif + +public: +#ifdef REGAMEDLL_ADD + CBitVec m_iCanHearMasks[VOICE_MAX_PLAYERS]; +#endif }; extern CGameRules DLLEXPORT *g_pGameRules; diff --git a/regamedll/dlls/multiplay_gamerules.cpp b/regamedll/dlls/multiplay_gamerules.cpp index 7ac7e341..2c96fba4 100644 --- a/regamedll/dlls/multiplay_gamerules.cpp +++ b/regamedll/dlls/multiplay_gamerules.cpp @@ -89,6 +89,13 @@ LINK_HOOK_CLASS_CUSTOM_CHAIN(bool, CCStrikeGameMgrHelper, CSGameRules, CanPlayer bool CCStrikeGameMgrHelper::__API_HOOK(CanPlayerHearPlayer)(CBasePlayer *pListener, CBasePlayer *pSender) { +#ifdef REGAMEDLL_ADD + if (!GetCanHearPlayer(pListener, pSender)) + { + return false; + } +#endif + switch ((int)sv_alltalk.value) { case 1: // allows everyone to talk @@ -125,6 +132,45 @@ bool CCStrikeGameMgrHelper::__API_HOOK(CanPlayerHearPlayer)(CBasePlayer *pListen } } +#ifdef REGAMEDLL_ADD +void CCStrikeGameMgrHelper::ResetCanHearPlayer(edict_t* pEdict) +{ + int index = ENTINDEX(pEdict) - 1; + + m_iCanHearMasks[index].Init(TRUE); + for (int iOtherClient = 0; iOtherClient < VOICE_MAX_PLAYERS; iOtherClient++) + { + if (index != iOtherClient) { + m_iCanHearMasks[iOtherClient][index] = TRUE; + } + } +} + +void CCStrikeGameMgrHelper::SetCanHearPlayer(CBasePlayer* pListener, CBasePlayer* pSender, bool bCanHear) +{ + if (!pListener->IsPlayer() || !pSender->IsPlayer()) + { + return; + } + + int listener = pListener->entindex() - 1; + int sender = pSender->entindex() - 1; + m_iCanHearMasks[listener][sender] = bCanHear ? TRUE : FALSE; +} + +bool CCStrikeGameMgrHelper::GetCanHearPlayer(CBasePlayer* pListener, CBasePlayer* pSender) +{ + if (!pListener->IsPlayer() || !pSender->IsPlayer()) + { + return true; + } + + int listener = pListener->entindex() - 1; + int sender = pSender->entindex() - 1; + return m_iCanHearMasks[listener][sender] == TRUE; +} +#endif + void Broadcast(const char *sentence) { char text[32]; diff --git a/regamedll/game_shared/voice_gamemgr.cpp b/regamedll/game_shared/voice_gamemgr.cpp index 309da626..e1d7488d 100644 --- a/regamedll/game_shared/voice_gamemgr.cpp +++ b/regamedll/game_shared/voice_gamemgr.cpp @@ -91,9 +91,13 @@ void CVoiceGameMgr::ClientConnected(edict_t *pEdict) int index = ENTINDEX(pEdict) - 1; // Clear out everything we use for deltas on this guy. - g_bWantModEnable[index] = true; + g_bWantModEnable[index] = TRUE; g_SentGameRulesMasks[index].Init(0); g_SentBanMasks[index].Init(0); + +#ifdef REGAMEDLL_ADD + m_pHelper->ResetCanHearPlayer(pEdict); +#endif } // Called to determine if the Receiver has muted (blocked) the Sender @@ -149,7 +153,7 @@ bool CVoiceGameMgr::ClientCommand(CBasePlayer *pPlayer, const char *cmd) VoiceServerDebug("CVoiceGameMgr::ClientCommand: VModEnable (%d)\n", !!Q_atoi(CMD_ARGV(1))); g_PlayerModEnable[playerClientIndex] = !!Q_atoi(CMD_ARGV(1)); - g_bWantModEnable[playerClientIndex] = false; + g_bWantModEnable[playerClientIndex] = FALSE; //UpdateMasks(); return true; } @@ -187,9 +191,10 @@ void CVoiceGameMgr::UpdateMasks() for (int iOtherClient = 0; iOtherClient < m_nMaxPlayers; iOtherClient++) { CBasePlayer *pSender = UTIL_PlayerByIndex(iOtherClient + 1); + if (pSender && m_pHelper->CanPlayerHearPlayer(pPlayer, pSender)) { - gameRulesMask[iOtherClient] = true; + gameRulesMask[iOtherClient] = TRUE; } } } diff --git a/regamedll/game_shared/voice_gamemgr.h b/regamedll/game_shared/voice_gamemgr.h index 2555b838..ef8dbf10 100644 --- a/regamedll/game_shared/voice_gamemgr.h +++ b/regamedll/game_shared/voice_gamemgr.h @@ -41,6 +41,11 @@ public: // Called each frame to determine which players are allowed to hear each other. This overrides // whatever squelch settings players have. virtual bool CanPlayerHearPlayer(CBasePlayer *pListener, CBasePlayer *pTalker) = 0; +#ifdef REGAMEDLL_ADD + virtual void ResetCanHearPlayer(edict_t* pEdict) = 0; + virtual void SetCanHearPlayer(CBasePlayer* pListener, CBasePlayer* pSender, bool bCanHear) = 0; + virtual bool GetCanHearPlayer(CBasePlayer* pListener, CBasePlayer* pSender) = 0; +#endif }; // CVoiceGameMgr manages which clients can hear which other clients. diff --git a/regamedll/public/regamedll/regamedll_api.h b/regamedll/public/regamedll/regamedll_api.h index 8c8e56dc..2b8951be 100644 --- a/regamedll/public/regamedll/regamedll_api.h +++ b/regamedll/public/regamedll/regamedll_api.h @@ -38,7 +38,7 @@ #include #define REGAMEDLL_API_VERSION_MAJOR 5 -#define REGAMEDLL_API_VERSION_MINOR 12 +#define REGAMEDLL_API_VERSION_MINOR 13 // CBasePlayer::Spawn hook typedef IHookChainClass IReGameHook_CBasePlayer_Spawn;