[Voice] Fix is_player_talking

This commit is contained in:
Diavolo 2022-08-14 17:15:45 +02:00
parent 8b224f6130
commit 0c22596161
No known key found for this signature in database
GPG Key ID: FA77F074E98D98A5
4 changed files with 16 additions and 3 deletions

View File

@ -71,7 +71,7 @@ namespace Components
SV_SendClientVoiceData(client); SV_SendClientVoiceData(client);
} }
bool Voice::OnSameTeam(Game::gentity_s* ent1, Game::gentity_s* ent2) bool Voice::OnSameTeam(const Game::gentity_s* ent1, const Game::gentity_s* ent2)
{ {
if (!ent1->client || !ent2->client) if (!ent1->client || !ent2->client)
{ {
@ -247,6 +247,12 @@ namespace Components
std::memset(s_playerMute, 0, sizeof(s_playerMute)); std::memset(s_playerMute, 0, sizeof(s_playerMute));
} }
bool Voice::CL_IsPlayerTalking_Hk([[maybe_unused]] Game::SessionData* session, [[maybe_unused]] const int localClientNum, const int talkingClientIndex)
{
// Skip all the Party related code
return Game::Voice_IsClientTalking(talkingClientIndex);
}
bool Voice::CL_IsPlayerMuted_Hk([[maybe_unused]] Game::SessionData* session, [[maybe_unused]] const int localClientNum, const int muteClientIndex) bool Voice::CL_IsPlayerMuted_Hk([[maybe_unused]] Game::SessionData* session, [[maybe_unused]] const int localClientNum, const int muteClientIndex)
{ {
AssertIn(muteClientIndex, Game::MAX_CLIENTS); AssertIn(muteClientIndex, Game::MAX_CLIENTS);
@ -316,7 +322,7 @@ namespace Components
} }
} }
void Voice::UI_Mute_player(int clientNum, const int localClientNum) void Voice::UI_Mute_player(const int clientNum, const int localClientNum)
{ {
CL_TogglePlayerMute(localClientNum, Game::sharedUiInfo->playerClientNums[clientNum]); CL_TogglePlayerMute(localClientNum, Game::sharedUiInfo->playerClientNums[clientNum]);
} }
@ -351,6 +357,7 @@ namespace Components
Utils::Hook(0x5AD945, CL_WriteVoicePacket_Hk, HOOK_CALL).install()->quick(); Utils::Hook(0x5AD945, CL_WriteVoicePacket_Hk, HOOK_CALL).install()->quick();
Utils::Hook(0x5A9E06, CL_VoicePacket_Hk, HOOK_CALL).install()->quick(); Utils::Hook(0x5A9E06, CL_VoicePacket_Hk, HOOK_CALL).install()->quick();
Utils::Hook(0x4AE740, CL_IsPlayerTalking_Hk, HOOK_JUMP).install()->quick();
Utils::Hook(0x4B6250, CL_IsPlayerMuted_Hk, HOOK_JUMP).install()->quick(); Utils::Hook(0x4B6250, CL_IsPlayerMuted_Hk, HOOK_JUMP).install()->quick();
Utils::Hook(0x4519F5, SV_SendClientMessages_Stub, HOOK_CALL).install()->quick(); Utils::Hook(0x4519F5, SV_SendClientMessages_Stub, HOOK_CALL).install()->quick();

View File

@ -24,7 +24,7 @@ namespace Components
static void SV_SendClientVoiceData(Game::client_t* client); static void SV_SendClientVoiceData(Game::client_t* client);
static void SV_SendClientMessages_Stub(Game::client_t* client, Game::msg_t* msg, unsigned char* snapshotMsgBuf); static void SV_SendClientMessages_Stub(Game::client_t* client, Game::msg_t* msg, unsigned char* snapshotMsgBuf);
static bool OnSameTeam(Game::gentity_s* ent1, Game::gentity_s* ent2); static bool OnSameTeam(const Game::gentity_s* ent1, const Game::gentity_s* ent2);
static void SV_QueueVoicePacket(int talkerNum, int clientNum, Game::VoicePacket_t* voicePacket); static void SV_QueueVoicePacket(int talkerNum, int clientNum, Game::VoicePacket_t* voicePacket);
static void G_BroadcastVoice(Game::gentity_s* talker, Game::VoicePacket_t* voicePacket); static void G_BroadcastVoice(Game::gentity_s* talker, Game::VoicePacket_t* voicePacket);
static void SV_UserVoice(Game::client_t* cl, Game::msg_t* msg); static void SV_UserVoice(Game::client_t* cl, Game::msg_t* msg);
@ -32,6 +32,7 @@ namespace Components
static void SV_VoicePacket(Game::netadr_t from, Game::msg_t* msg); static void SV_VoicePacket(Game::netadr_t from, Game::msg_t* msg);
static void CL_ClearMutedList(); static void CL_ClearMutedList();
static bool CL_IsPlayerTalking_Hk(Game::SessionData* session, int localClientNum, int talkingClientIndex);
static bool CL_IsPlayerMuted_Hk(Game::SessionData* session, int localClientNum, int muteClientIndex); static bool CL_IsPlayerMuted_Hk(Game::SessionData* session, int localClientNum, int muteClientIndex);
static void CL_MutePlayer_Hk(Game::SessionData* session, int muteClientIndex); static void CL_MutePlayer_Hk(Game::SessionData* session, int muteClientIndex);
static void Voice_UnmuteMember_Hk(Game::SessionData* session, int clientNum); static void Voice_UnmuteMember_Hk(Game::SessionData* session, int clientNum);

View File

@ -486,7 +486,9 @@ namespace Game
I_strncpyz_t I_strncpyz = I_strncpyz_t(0x4D6F80); I_strncpyz_t I_strncpyz = I_strncpyz_t(0x4D6F80);
XNAddrToString_t XNAddrToString = XNAddrToString_t(0x452690); XNAddrToString_t XNAddrToString = XNAddrToString_t(0x452690);
Voice_IncomingVoiceData_t Voice_IncomingVoiceData = Voice_IncomingVoiceData_t(0x5001A0); Voice_IncomingVoiceData_t Voice_IncomingVoiceData = Voice_IncomingVoiceData_t(0x5001A0);
Voice_IsClientTalking_t Voice_IsClientTalking = Voice_IsClientTalking_t(0x4D9D20);
XAssetHeader* DB_XAssetPool = reinterpret_cast<XAssetHeader*>(0x7998A8); XAssetHeader* DB_XAssetPool = reinterpret_cast<XAssetHeader*>(0x7998A8);
unsigned int* g_poolSize = reinterpret_cast<unsigned int*>(0x7995E8); unsigned int* g_poolSize = reinterpret_cast<unsigned int*>(0x7995E8);

View File

@ -1176,6 +1176,9 @@ namespace Game
typedef int(__cdecl * Voice_IncomingVoiceData_t)(const SessionData* session, int clientNum, unsigned char* data, int size); typedef int(__cdecl * Voice_IncomingVoiceData_t)(const SessionData* session, int clientNum, unsigned char* data, int size);
extern Voice_IncomingVoiceData_t Voice_IncomingVoiceData; extern Voice_IncomingVoiceData_t Voice_IncomingVoiceData;
typedef bool(__cdecl * Voice_IsClientTalking_t)(int clientNum);
extern Voice_IsClientTalking_t Voice_IsClientTalking;
constexpr std::size_t STATIC_MAX_LOCAL_CLIENTS = 1; constexpr std::size_t STATIC_MAX_LOCAL_CLIENTS = 1;
constexpr std::size_t MAX_LOCAL_CLIENTS = 1; constexpr std::size_t MAX_LOCAL_CLIENTS = 1;
constexpr std::size_t MAX_CLIENTS = 18; constexpr std::size_t MAX_CLIENTS = 18;