mirror of
https://github.com/s1lentq/ReGameDLL_CS.git
synced 2024-12-26 14:45:38 +03:00
Add API to set if player can hear another player (#467)
* Add API to set if player can hear another player
This commit is contained in:
parent
19269aa450
commit
27b2a8c8c9
@ -1,3 +1,3 @@
|
||||
majorVersion=5
|
||||
minorVersion=12
|
||||
minorVersion=13
|
||||
maintenanceVersion=0
|
||||
|
@ -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<VOICE_MAX_PLAYERS> m_iCanHearMasks[VOICE_MAX_PLAYERS];
|
||||
#endif
|
||||
};
|
||||
|
||||
extern CGameRules DLLEXPORT *g_pGameRules;
|
||||
|
@ -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];
|
||||
|
@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -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.
|
||||
|
@ -38,7 +38,7 @@
|
||||
#include <API/CSInterfaces.h>
|
||||
|
||||
#define REGAMEDLL_API_VERSION_MAJOR 5
|
||||
#define REGAMEDLL_API_VERSION_MINOR 12
|
||||
#define REGAMEDLL_API_VERSION_MINOR 13
|
||||
|
||||
// CBasePlayer::Spawn hook
|
||||
typedef IHookChainClass<void, class CBasePlayer> IReGameHook_CBasePlayer_Spawn;
|
||||
|
Loading…
Reference in New Issue
Block a user