Files
wowdecomp/WoW/Source/Game/GameClient/ComSatClient.cpp
T
SatyandClaude Opus 5.5 46b5adf64f Port FriendList, Player_C, Unit_C and GameObject_C modules
- FriendList: remaining methods and 28 Lua scripts, FriendListModuleLoaded
- Player_C: remaining functions incl. click-to-move (ClickToMove, CTMFace,
  CTMClickTerrain, CTMAttackUnit, CTMInteractGO), dance, virtual items,
  sound and skill-rank overrides
- Unit_C: tracking (HandleTracking and helpers, SetTrackingTarget/Direction),
  selection circles, spell visual overrides, mirror image, flag-2 changes,
  scale update, missile trajectory (ComputeMissileTrajectory,
  SendFinalMissileTrajectoryUpdate, StartMissileTrajectoryTargeting) and
  CMissileCollision (Init, unit ranking, hit spheres)
- GameObject_C: IsLocked, UseObject, TypeBase CanUseNow/CheckRange/Use/
  CanChangeCursor, Ritual and MeetingStone types, virtual overrides,
  property helpers named from the binary's property table
- Dependencies: ProjectTex::Render2d, weapon trail chain (SWING,
  WTOBJECT::SetDrawTrail), GxSwizzleColor, CAaBox::Expand/Center,
  CVehicle_C::PlayBoneAnimOrFallback, RuneInfo/PetitionInfo/ClassTrainer/
  ComSat helpers, CalendarEventTables ctor
- DBCache: InvalidateIntKey, RetryItem, SetTemporary, ~DBCACHEHASH
- Template instances, deleting dtors and TSHashTable/WowClientDB instances
  recorded in their OFFSET lists

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
2026-10-02 12:07:58 +02:00

1094 lines
29 KiB
C++

#include "ComSatClient.h"
#include <cstring>
#include "WoW/Source/Ui/RaidInfo.h"
#include "WoW/Source/Ui/PartyFrame.h"
#include "WoW/Source/WowSvcs/WowSvcsClient/FriendList.h"
#include "WoW/Source/Ui/ChatFrame.h"
#include <new>
#include "Engine/Source/Storm/H/stpl.h"
#include "Engine/Source/ConsoleBase/ConsoleVar.h"
#include "Engine/Source/Event/Event.h"
#include "Engine/Source/Storm/H/storm.h"
#include "Engine/Source/Storm/Source/SLock.h"
#include "Engine/Source/Storm/Source/SThread.h"
#include "WoW/Source/Game/GameClient/ComSatThread.h"
#include "WoW/Source/SoundInterface/SoundInterface2.h"
#include "WoW/Source/Ui/UIBindings.h"
#include "WoW/Source/Ui/GameUI.h"
#include "WoW/Source/Ui/ScriptEvents.h"
#include "WoW/Source/Ui/Types.h"
#include "WoW/Source/Net/Types.h"
#include "Engine/Source/Base/CDataStore.h"
#include "Engine/Source/FrameScript/FrameScript.h"
#include "WoW/Source/WowSvcs/WowSvcsClient/ClientServices.h"
#include "WoW/Source/ObjectMgrClient/ObjectMgrClient.h"
#include "WoW/Source/DB/DBClient/DBCacheInstances.h"
// STATIC: 0x00D31AA0
COMSATDATA s_comsatData[32];
// STATIC: 0x00D37CA0
int32_t s_voiceActivation;
// STATIC: 0x00AF2A48
static ComSatClientAllocator s_comsatAllocator;
// STATIC: 0x00D37CA4
static float unk_D37CA4;
// STATIC: 0x00D37CA8
static float unk_D37CA8;
// STATIC: 0x00D37CAC
static float unk_D37CAC;
// STATIC: 0x00D37CB0
static int32_t unk_D37CB0;
// STATIC: 0x00D37CB8
static CVar* unk_D37CB8;
// STATIC: 0x00D37CBC
static CVar* unk_D37CBC;
// STATIC: 0x00D37CC0
static CVar* unk_D37CC0;
// STATIC: 0x00D37CD0
static float unk_D37CD0;
// STATIC: 0x00D37CD4
static float unk_D37CD4;
// STATIC: 0x00D37CD8
static float unk_D37CD8;
// STATIC: 0x00D37CDC
static float unk_D37CDC;
// STATIC: 0x00D37CE0
static float unk_D37CE0;
// STATIC: 0x00D37CE4
static float unk_D37CE4;
// STATIC: 0x00AF29BC
int32_t s_pushToTalkKey = -1;
// STATIC: 0x00D31A88
uint32_t s_pushToTalkModifiers;
// STATIC: 0x00D37D00
CVar* s_cvarPushToTalkButton;
// STATIC: 0x00D37D04
int32_t s_voiceChatWasEnabled;
// STATIC: 0x00D37D1C
uint32_t s_pushToTalkMouseButton;
// STATIC: 0x00D37D34
static TSFixedArray<ComSatCallback> s_comsatCallbacks;
// STATIC: 0x00D37D54
static SMutex unk_D37D54;
// STATIC: 0x00D37D88
TSHashTable<TALKINGPLAYER, CHashKeyGUID> unk_D37D88;
// STATIC: 0x00D37DB0
static TSHashTable<MUTEDPLAYER, CHashKeyGUID> unk_D37DB0;
// STATIC: 0x00D37D44
static TSGrowableArray<ComSatEvent> s_comSatEvents;
// STATIC: 0x00D37D18
int32_t s_comsatDisabledByClient;
// STATIC: 0x00D37D5C
SCritSect s_comsatDeviceLock;
// STATIC: 0x00D37DD8
static int32_t s_lastFoundSession;
// STATIC: 0x00AF29B4
int32_t s_currentSession = -1;
// VERIFY: df726b6e auto
// OFFSET: 0x007DBC70
static int32_t ParseKeyNameToKeyCode(const char* name) {
if (!name || !*name) {
return -1;
}
if (!name[1] && name[0] > ' ') {
return name[0];
}
if (!SStrCmpI(name, "LSHIFT", STORM_MAX_STR)) {
return KEY_LSHIFT;
}
if (!SStrCmpI(name, "RSHIFT", STORM_MAX_STR)) {
return KEY_RSHIFT;
}
if (!SStrCmpI(name, "LCTRL", STORM_MAX_STR)) {
return KEY_LCONTROL;
}
if (!SStrCmpI(name, "RCTRL", STORM_MAX_STR)) {
return KEY_RCONTROL;
}
if (!SStrCmpI(name, "LALT", STORM_MAX_STR)) {
return KEY_LALT;
}
if (!SStrCmpI(name, "RALT", STORM_MAX_STR)) {
return KEY_RALT;
}
if (!SStrCmpI(name, "SPACE", STORM_MAX_STR)) {
return KEY_SPACE;
}
if (!SStrCmpI(name, "NUMPADPLUS", STORM_MAX_STR)) {
return KEY_NUMPAD_PLUS;
}
if (!SStrCmpI(name, "NUMPADMINUS", STORM_MAX_STR)) {
return KEY_NUMPAD_MINUS;
}
if (!SStrCmpI(name, "NUMPADMULTIPLY", STORM_MAX_STR)) {
return KEY_NUMPAD_MULTIPLY;
}
if (!SStrCmpI(name, "NUMPADDIVIDE", STORM_MAX_STR)) {
return KEY_NUMPAD_DIVIDE;
}
if (!SStrCmpI(name, "NUMPADDECIMAL", STORM_MAX_STR)) {
return KEY_NUMPAD_DECIMAL;
}
if (!SStrCmpI(name, "NUMPADEQUALS", STORM_MAX_STR)) {
return KEY_NUMPAD_EQUALS;
}
if (SStrStrI(name, "NUMPAD")) {
if (name[6] >= 0 && name[6] <= '9') {
return name[6] - '0' + KEY_NUMPAD0;
}
return -1;
}
if (!SStrCmpI(name, "ESCAPE", STORM_MAX_STR)) {
return KEY_ESCAPE;
}
if (!SStrCmpI(name, "ENTER", STORM_MAX_STR)) {
return KEY_ENTER;
}
if (!SStrCmpI(name, "BACKSPACE", STORM_MAX_STR)) {
return KEY_BACKSPACE;
}
if (!SStrCmpI(name, "TAB", STORM_MAX_STR)) {
return KEY_TAB;
}
if (!SStrCmpI(name, "LEFT", STORM_MAX_STR)) {
return KEY_LEFT;
}
if (!SStrCmpI(name, "UP", STORM_MAX_STR)) {
return KEY_UP;
}
if (!SStrCmpI(name, "RIGHT", STORM_MAX_STR)) {
return KEY_RIGHT;
}
if (!SStrCmpI(name, "DOWN", STORM_MAX_STR)) {
return KEY_DOWN;
}
if (!SStrCmpI(name, "INSERT", STORM_MAX_STR)) {
return KEY_INSERT;
}
if (!SStrCmpI(name, "DELETE", STORM_MAX_STR)) {
return KEY_DELETE;
}
if (!SStrCmpI(name, "HOME", STORM_MAX_STR)) {
return KEY_HOME;
}
if (!SStrCmpI(name, "END", STORM_MAX_STR)) {
return KEY_END;
}
if (!SStrCmpI(name, "PAGEUP", STORM_MAX_STR)) {
return KEY_PAGEUP;
}
if (!SStrCmpI(name, "PAGEDOWN", STORM_MAX_STR)) {
return KEY_PAGEDOWN;
}
if (!SStrCmpI(name, "NUMLOCK", STORM_MAX_STR)) {
return KEY_NUMLOCK;
}
if (!SStrCmpI(name, "CAPSLOCK", STORM_MAX_STR)) {
return KEY_CAPSLOCK;
}
if (!SStrCmpI(name, "PRINTSCREEN", STORM_MAX_STR)) {
return KEY_PRINTSCREEN;
}
if (*name == 'F') {
return SStrToInt(name + 1) + KEY_F1 - 1;
}
return -1;
}
// VERIFY: 4b73a2c5 manual
// OFFSET: 0x007DCA90
void AddComSatEvent(uint32_t type, float value, uint64_t guid) {
ComSatEvent* event = s_comSatEvents.New();
if (event) {
event->m_floatValue = value;
event->m_type = type;
event->m_guid = guid;
}
}
// VERIFY: ebc8d780 manual
// OFFSET: 0x007DCB10
void AddComSatEvent(uint32_t type, uint32_t value, uint64_t guid) {
ComSatEvent* event = s_comSatEvents.New();
if (event) {
event->m_type = type;
event->m_guid = guid;
event->m_uintValue = value;
}
}
// VERIFY: 3ca2706b auto
// OFFSET: 0x007DC5C0
static void ResetVoiceVolumeState() {
unk_D37CA4 = 0.0f;
unk_D37CA8 = 0.0f;
unk_D37CB0 = 0;
unk_D37CAC = 0.0f;
unk_D37CDC = 0.0f;
unk_D37CE0 = 0.0f;
unk_D37CE4 = 0.0f;
if (unk_D37CB8) {
unk_D37CD0 = unk_D37CB8->m_floatValue;
SI2::SetChannelGroupVolume(0, unk_D37CD0);
} else {
unk_D37CD0 = 0.0f;
}
if (unk_D37CBC) {
unk_D37CD4 = unk_D37CBC->m_floatValue;
SI2::SetChannelGroupVolume(1, unk_D37CD4);
} else {
unk_D37CD4 = 0.0f;
}
if (unk_D37CC0) {
unk_D37CD8 = unk_D37CC0->m_floatValue;
SI2::SetChannelGroupVolume(2, unk_D37CD8);
} else {
unk_D37CD8 = 0.0f;
}
}
// VERIFY: 3564923b manual
// OFFSET: 0x007DC730
void* ComSatClientAllocator::Alloc(uint32_t size) {
return SMemAlloc(size, __FILE__, __LINE__, 0);
}
// VERIFY: 0d60f70a manual
// OFFSET: 0x007DC750
void ComSatClientAllocator::Free(void* ptr) {
SMemFree(ptr, __FILE__, __LINE__, 0);
}
// VERIFY: bf8e209f manual
// OFFSET: 0x007DF770
static void ProcessComSatCallbacks() {
for (uint32_t i = 0; i < s_comsatCallbacks.Count(); i++) {
ComSatCallback& callback = s_comsatCallbacks[i];
switch (callback.m_type) {
case 0:
Comsat::VoiceStart();
break;
case 1:
Comsat::VoiceStop();
break;
case 2:
Comsat::VoicePlateStart(callback.unk_0008, callback.unk_0010);
break;
case 3:
Comsat::VoicePlateStop(callback.unk_0008, callback.unk_0010);
break;
default:
break;
}
}
s_comsatCallbacks.Clear();
}
// VERIFY: 7b6b6b9a auto
// OFFSET: 0x007DF900
void ComSatClient_Shutdown() {
if (ComSatThread::s_threadRunning) {
ComSatThread::s_threadRunning = 0;
ComSatThread::s_threadShutdownEvent.Set();
ComSatThread::s_comsatThread.Wait(0xFFFFFFFF);
}
ProcessComSatCallbacks();
EventUnregister(EVENT_ID_IDLE, VoiceChat_TickWrapper);
ComSat::Interface::Destroy(ComSatThread::s_comsat, s_comsatAllocator);
ComSatThread::s_comsat = nullptr;
unk_D37DB0.InternalClear(0);
unk_D37D88.InternalClear(0);
if (unk_D37D54.Valid()) {
unk_D37D54.Close();
unk_D37D54.Release();
}
ResetVoiceVolumeState();
SI2::VoiceChat_DestroyChatSystem();
}
// VERIFY: 9c9c6262 auto
// OFFSET: 0x007DC9C0
void UpdatePushToTalkKey() {
s_pushToTalkKey = -1;
s_pushToTalkMouseButton = 0;
s_pushToTalkModifiers = 0;
if (!s_cvarPushToTalkButton) {
return;
}
const char* binding = s_cvarPushToTalkButton->m_stringValue.m_str;
if (!binding || !*binding) {
return;
}
s_pushToTalkModifiers = 0;
CGUIBindings::AddModifiers(s_pushToTalkModifiers, binding);
s_pushToTalkMouseButton = StringToMouseButton(binding);
if (!s_pushToTalkMouseButton) {
s_pushToTalkKey = ParseKeyNameToKeyCode(binding);
}
}
// VERIFY: 968200fd manual
// OFFSET: 0x007DB600
int32_t ComSatClient_IsTalkerSquelched(WOWGUID guid, uint32_t session) {
if (!guid || session > 31) {
return 0;
}
s_comsatDeviceLock.Enter();
COMSATDATA& data = s_comsatData[session];
for (int32_t i = 0; i < static_cast<int32_t>(data.m_numMembers); i++) {
if (data.m_members[i].m_guid == guid) {
int32_t result = data.m_members[i].m_flags & 0x8;
s_comsatDeviceLock.Leave();
return result;
}
}
s_comsatDeviceLock.Leave();
return 0;
}
// VERIFY: 1024d571 manual
// OFFSET: 0x007DB6B0
int32_t ComSatClient_IsTalkerSquelchedInChannel(WOWGUID guid, int32_t type, const char* name) {
int32_t session = ComSatClient_FindSessionByTypeAndName(type, name);
return session >= 0 ? ComSatClient_IsTalkerSquelched(guid, session) : 0;
}
// VERIFY: 75ebd9f3 manual
// OFFSET: 0x007DB6E0
int32_t ComSatClient_IsMemberVoiceActive(WOWGUID guid, uint32_t session) {
if (!guid || session > 31) {
return 0;
}
s_comsatDeviceLock.Enter();
COMSATDATA& data = s_comsatData[session];
for (int32_t i = 0; i < static_cast<int32_t>(data.m_numMembers); i++) {
if (data.m_members[i].m_guid == guid) {
int32_t result = data.m_members[i].m_flags & 0x40;
s_comsatDeviceLock.Leave();
return result;
}
}
s_comsatDeviceLock.Leave();
return 0;
}
// VERIFY: cc56d1d4 manual
// OFFSET: 0x007DB770
int32_t ComSatClient_IsMemberInVoiceSession(WOWGUID guid, int32_t type, const char* name) {
int32_t session = ComSatClient_FindSessionByTypeAndName(type, name);
return session >= 0 ? ComSatClient_IsMemberVoiceActive(guid, session) : 0;
}
// VERIFY: 8c8597f1 manual
// OFFSET: 0x007DB7A0
int32_t ComSatClient_GetMemberVoiceStatus(WOWGUID guid, uint32_t session) {
if (!guid || session > 31) {
return 0;
}
s_comsatDeviceLock.Enter();
COMSATDATA& data = s_comsatData[session];
for (int32_t i = 0; i < static_cast<int32_t>(data.m_numMembers); i++) {
if (data.m_members[i].m_guid == guid) {
int32_t result = data.m_members[i].m_flags & 0x4;
s_comsatDeviceLock.Leave();
return result;
}
}
s_comsatDeviceLock.Leave();
return 0;
}
// VERIFY: dd54fe16 manual
// OFFSET: 0x007DB830
int32_t ComSatClient_Unk7DB830(WOWGUID guid, int32_t type, const char* name) {
int32_t session = ComSatClient_FindSessionByTypeAndName(type, name);
return session >= 0 ? ComSatClient_GetMemberVoiceStatus(guid, session) : 0;
}
// VERIFY: bc5e270c auto
// OFFSET: 0x007DBAB0
int32_t ComSatClient_IsComsatDisabledByClient() {
return s_comsatDisabledByClient;
}
// VERIFY: fe028376 auto
// OFFSET: 0x007DADE0
void ComSatClient_SetOutputDevice(int32_t index) {
ComSat::DeviceInfo devices[20];
s_comsatDeviceLock.Enter();
ComSat::Interface* comsat = ComSatThread::s_comsat;
if (comsat && index < comsat->EnumerateOutputDevices(devices, 20)) {
comsat->LocalTalkerChangeOutputDevice(0, index);
}
s_comsatDeviceLock.Leave();
}
// VERIFY: a22afe03 auto
// OFFSET: 0x007DAF30
void ComSatClient_SetCaptureDevice(int32_t index) {
ComSat::DeviceInfo devices[20];
s_comsatDeviceLock.Enter();
ComSat::Interface* comsat = ComSatThread::s_comsat;
if (comsat && index < comsat->EnumerateCaptureDevices(devices, 20)) {
comsat->LocalTalkerChangeCaptureDevice(0, index);
}
s_comsatDeviceLock.Leave();
}
// VERIFY: 6dafafe1 manual
// OFFSET: 0x007DB5C0
int32_t ComSatClient_GetCurrentSessionType() {
if (s_currentSession >= 0) {
return s_comsatData[s_currentSession].m_type;
}
return 4;
}
// VERIFY: 706dd5de manual
// OFFSET: 0x007DB5E0
const char* ComSatClient_GetCurrentSessionName() {
if (s_currentSession >= 0) {
return s_comsatData[s_currentSession].m_name;
}
return nullptr;
}
// VERIFY: a1da55e8 manual
// OFFSET: 0x007DB560
int32_t ComSatClient_HasSession(int32_t type, const char* name) {
return ComSatClient_FindSessionByTypeAndName(type, name) >= 0;
}
// VERIFY: 1f2e0bf3 manual
// OFFSET: 0x007DB400
int32_t ComSatClient_FindSessionByTypeAndName(int32_t type, const char* name) {
int32_t cached = s_lastFoundSession;
if (s_comsatData[cached].m_type == type) {
if (type) {
return cached;
}
if (!SStrCmpUTF8I(s_comsatData[cached].m_name, name, 0x7FFFFFFF)) {
return s_lastFoundSession;
}
}
if (!type && !name) {
return -1;
}
for (int32_t i = 0; i < 32; i++) {
COMSATDATA* data = &s_comsatData[i];
if (data->m_sessionID && data->m_type == type && (type || !SStrCmpUTF8I(data->m_name, name, 0x7FFFFFFF))) {
s_lastFoundSession = i;
return i;
}
}
return -1;
}
// VERIFY: 43d91719 auto
// OFFSET: 0x007DB4A0
static void NameQueryCallback(int32_t id, const WOWGUID& guid, void* param, bool success) {
if (success) {
ComSatClient_SendEvent(static_cast<int32_t>(reinterpret_cast<intptr_t>(param)), guid);
}
}
// VERIFY: 9683c504 auto
// OFFSET: 0x007DB4D0
void ComSatClient_SendEvent(int32_t event, WOWGUID guid) {
if (!CGGameUI::m_initialized) {
return;
}
const char* name = reinterpret_cast<const char*>(g_nameDBCache.GetRecord(guid.m_guid, guid, NameQueryCallback, reinterpret_cast<void*>(static_cast<intptr_t>(event)), false));
if (!name) {
name = FrameScript_GetText("UNKNOWN", -1, GENDER_NOT_APPLICABLE);
}
const char* token = Script_GetTokenFromGUID(&guid);
if (!name || !*name) {
return;
}
if (token) {
FrameScript_SignalEvent(event, "%s%s", name, token);
} else {
FrameScript_SignalEvent(event, "%s", name);
}
}
// VERIFY: 83ce1870 auto
// OFFSET: 0x007DEEC0
bool ComSatClient_IsPlayerMuted(WOWGUID guid) {
return unk_D37DB0.Ptr(static_cast<uint32_t>(guid.m_guid), CHashKeyGUID(guid.m_guid)) != nullptr;
}
// VERIFY: 0d87f0e1 manual
// OFFSET: 0x007DF150
static void ComSatClient_SetCurrentSessionI(int32_t index) {
int32_t type;
const char* name;
if (index == -1) {
AddComSatEvent(5, 0u, 0ull);
s_currentSession = -1;
type = 4;
name = "";
WOWGUID player = ClntObjMgrGetActivePlayer();
if (unk_D37D88.Ptr(static_cast<uint32_t>(player.m_guid), CHashKeyGUID(player.m_guid))) {
Script_SendUnitSignal(player, SCRIPT_EVENT_VOICE_STOP);
ComSatClient_SendEvent(SCRIPT_EVENT_VOICE_PLATE_STOP, player);
}
} else {
AddComSatEvent(5, 0u, s_comsatData[index].m_sessionID);
s_currentSession = index;
type = s_comsatData[index].m_type;
name = s_comsatData[index].m_name;
}
CDataStore msg;
msg.Put(static_cast<uint32_t>(CMSG_SET_ACTIVE_VOICE_CHANNEL));
msg.Put(static_cast<uint32_t>(type));
msg.PutString(name);
msg.Finalize();
ClientServices::Send2(&msg);
if (CGGameUI::m_initialized) {
FrameScript_SignalEvent(SCRIPT_EVENT_VOICE_SESSIONS_UPDATE, nullptr);
}
}
// VERIFY: 26a86cb9 manual
// OFFSET: 0x007DF290
int32_t ComSatClient_SetCurrentSession(int32_t type, const char* name) {
int32_t index = ComSatClient_FindSessionByTypeAndName(type, name);
if (index < 0) {
return 0;
}
ComSatClient_SetCurrentSessionI(index);
return 1;
}
// VERIFY: 4c0e0114 manual
// OFFSET: 0x007DF2C0
void ComSatClient_DisableCurrentSession() {
ComSatClient_SetCurrentSessionI(-1);
}
// VERIFY: ee86b5ab auto
// OFFSET: 0x007DB690
int32_t ComSatClient_IsTalkerSquelchedInCurrent(WOWGUID guid) {
return ComSatClient_IsTalkerSquelched(guid, s_currentSession);
}
// STATIC: 0x00ADC098
const char* s_sessionTypeNames[3] = { "Battleground", "Party", "Raid" };
// VERIFY: c896b767 auto
// OFFSET: 0x007DB860
int32_t ComSatClient_DetermineSessionTypeFromName(const char* name) {
if (!name || !*name) {
return 4;
}
if (!SStrCmpI(name, s_sessionTypeNames[1], STORM_MAX_STR)) {
return 2;
}
if (!SStrCmpI(name, s_sessionTypeNames[2], STORM_MAX_STR)) {
return 3;
}
return !SStrCmpI(name, s_sessionTypeNames[0], STORM_MAX_STR);
}
// VERIFY: ea38ef44 auto
// OFFSET: 0x007DEB00
static void ComSatClient_LeaveSessionNotifyAll(int32_t index) {
for (int32_t i = 0; i < static_cast<int32_t>(s_comsatData[index].m_numMembers); i++) {
WOWGUID guid = s_comsatData[index].m_members[i].m_guid;
if (!guid || guid == ClntObjMgrGetActivePlayer()) {
continue;
}
Script_SendUnitSignal(guid, SCRIPT_EVENT_VOICE_STOP);
ComSatClient_SendEvent(SCRIPT_EVENT_VOICE_PLATE_STOP, guid);
TALKINGPLAYER* talker = unk_D37D88.Ptr(static_cast<uint32_t>(guid.m_guid), CHashKeyGUID(guid.m_guid));
if (talker) {
unk_D37D88.Delete(talker);
}
if (--unk_D37CB0 < 0) {
unk_D37CB0 = 0;
}
}
}
// VERIFY: ccd50750 manual
// OFFSET: 0x007DED60
void ComSatClient_LeaveAllSessions(WOWGUID guid) {
s_comsatDeviceLock.Enter();
ComSat::Interface* comsat = ComSatThread::s_comsat;
if (comsat) {
int32_t index = 0;
while (!static_cast<uint32_t>(s_comsatData[index].m_sessionID)) {
if (++index >= 32) {
break;
}
}
if (index < 32) {
comsat->SessionRemove(s_comsatData[index].m_sessionID, guid.m_guid);
comsat->SessionDestroy(s_comsatData[index].m_sessionID);
ComSatClient_LeaveSessionNotifyAll(index);
s_comsatData[index].m_sessionID = 0;
s_comsatData[index].m_name[0] = 0;
s_comsatData[index].m_type = 4;
s_comsatData[index].m_numMembers = 0;
if (s_currentSession == index) {
s_currentSession = -1;
WOWGUID player = ClntObjMgrGetActivePlayer();
if (unk_D37D88.Ptr(static_cast<uint32_t>(player.m_guid), CHashKeyGUID(player.m_guid))) {
Script_SendUnitSignal(player, SCRIPT_EVENT_VOICE_STOP);
ComSatClient_SendEvent(SCRIPT_EVENT_VOICE_PLATE_STOP, player);
}
}
}
if (CGGameUI::m_initialized) {
FrameScript_SignalEvent(SCRIPT_EVENT_VOICE_LEFT_SESSION, nullptr);
if (CGGameUI::m_initialized) {
FrameScript_SignalEvent(SCRIPT_EVENT_VOICE_SESSIONS_UPDATE, nullptr);
}
}
}
s_comsatDeviceLock.Leave();
}
// VERIFY: 02135c1e manual
// OFFSET: 0x007DB580
int32_t ComSatClient_IsCurrentSession(uint64_t session) {
return s_currentSession >= 0 && s_comsatData[s_currentSession].m_sessionID == session;
}
// VERIFY: 242ea58b manual
// OFFSET: 0x007DC830
static bool FillComsatData(uint64_t session, int32_t type, const char* name) {
int32_t index = -1;
int32_t i;
for (i = 0; i < 32; i++) {
if (s_comsatData[i].m_sessionID == session) {
break;
}
if (index == -1 && !static_cast<uint32_t>(s_comsatData[i].m_sessionID)) {
index = i;
}
}
if (i < 32) {
index = i;
s_comsatData[index].m_sessionID = 0;
}
if (index == -1) {
return false;
}
s_comsatData[index].m_sessionID = session;
s_comsatData[index].m_type = type;
s_comsatData[index].m_numMembers = 0;
if (type) {
s_comsatData[index].m_name[0] = 0;
} else {
SStrCopy(s_comsatData[index].m_name, name, sizeof(s_comsatData[index].m_name));
}
if (CGGameUI::m_initialized) {
FrameScript_SignalEvent(SCRIPT_EVENT_VOICE_SESSIONS_UPDATE, nullptr);
}
CGChat::NewVoiceSession(name, type);
return true;
}
// VERIFY: 0521ea5d auto
// OFFSET: 0x007DD6F0
static bool ComSatClient_IsPlayerTalking(WOWGUID guid) {
return unk_D37D88.Ptr(static_cast<uint32_t>(guid.m_guid), CHashKeyGUID(guid.m_guid)) != nullptr;
}
// VERIFY: 6f6aa26e auto
// OFFSET: 0x007DE440
void ComSatClient_PopulateSessionDataWithoutJoin(uint64_t session, int32_t type, const char* name, uint64_t self) {
if (!name) {
return;
}
s_comsatDeviceLock.Enter();
ComSat::Interface* comsat = ComSatThread::s_comsat;
if (!comsat) {
s_comsatDeviceLock.Leave();
return;
}
if (comsat->SessionCreate(session)) {
comsat->SessionAddLocal(session, 0, self);
if (!FillComsatData(session, type, name)) {
s_comsatDeviceLock.Leave();
return;
}
if (type == 2 || type == 3 || type == 1) {
Script_SendUniqueSignal(SCRIPT_EVENT_VOICE_STATUS_UPDATE);
}
WOWGUID player = ClntObjMgrGetActivePlayer();
if (ComSatClient_IsPlayerTalking(player)) {
Script_SendUnitSignal(player, SCRIPT_EVENT_VOICE_START);
ComSatClient_SendEvent(SCRIPT_EVENT_VOICE_PLATE_START, player);
}
if ((type == 2 || type == 3 || type == 1) && (CGPartyInfo::m_members[0] || CGRaidInfo::m_numMembers)) {
CGChat::JoiningParty(type == 3 || type == 1, type == 1);
}
}
CGChat::VoiceSessionUpdate(type ? "" : name, type);
s_comsatDeviceLock.Leave();
}
// VERIFY: 6ce4a12d manual
// OFFSET: 0x007DE5A0
void VoiceSessionRosterUpdate(uint64_t session, uint16_t networkId, int32_t type, const char* name, const uint8_t* key, uint64_t self, uint8_t selfNetworkId, uint8_t selfFlags, int32_t count, VoiceRosterMember* members) {
s_comsatDeviceLock.Enter();
ComSat::Interface* comsat = ComSatThread::s_comsat;
if (!comsat || !name) {
s_comsatDeviceLock.Leave();
return;
}
if (comsat->SessionCreate(session)) {
comsat->SessionAddLocal(session, 0, self);
if (!FillComsatData(session, type, name)) {
s_comsatDeviceLock.Leave();
return;
}
WOWGUID player = ClntObjMgrGetActivePlayer();
if (ComSatClient_IsPlayerTalking(player)) {
Script_SendUnitSignal(player, SCRIPT_EVENT_VOICE_START);
ComSatClient_SendEvent(SCRIPT_EVENT_VOICE_PLATE_START, player);
}
if ((type == 2 || type == 3 || type == 1) && (CGPartyInfo::m_members[0] || CGRaidInfo::m_numMembers)) {
CGChat::JoiningParty(type == 3 || type == 1, type == 1);
}
}
comsat->SessionSetNetworkId(session, networkId);
comsat->SessionSetTalkerNetworkIdLocal(session, self, selfNetworkId);
int32_t index;
for (index = 0; index < 32; index++) {
if (s_comsatData[index].m_sessionID == session) {
break;
}
}
if (index < 32 && s_comsatData[index].m_type != type) {
s_comsatData[index].m_type = type;
if (type) {
s_comsatData[index].m_name[0] = 0;
} else {
SStrCopy(s_comsatData[index].m_name, name, sizeof(s_comsatData[index].m_name));
}
}
int32_t talkers = comsat->SessionNumMembers(session);
for (int32_t i = 0; i < talkers; i++) {
uint64_t talker;
uint8_t flags;
if (!comsat->SessionGetTalkerByIndex(session, i, talker, flags) || flags != 0xFF) {
continue;
}
int32_t j = 0;
if (count >= 0) {
for (; j <= count; j++) {
if (members[j].m_guid.m_guid == talker) {
break;
}
}
}
if (j != count) {
continue;
}
comsat->SessionRemove(session, talker);
i--;
talkers--;
if (unk_D37D88.Ptr(static_cast<uint32_t>(talker), CHashKeyGUID(talker))) {
WOWGUID guid;
guid.m_guid = talker;
Script_SendUnitSignal(guid, SCRIPT_EVENT_VOICE_STOP);
ComSatClient_SendEvent(SCRIPT_EVENT_VOICE_PLATE_STOP, guid);
TALKINGPLAYER* talking = unk_D37D88.Ptr(static_cast<uint32_t>(talker), CHashKeyGUID(talker));
if (talking) {
unk_D37D88.Delete(talking);
}
}
}
uint8_t sessionKey[16];
memcpy(sessionKey, key, sizeof(sessionKey));
for (int32_t i = 0; i < count; i++) {
comsat->SessionAddRemote(session, members[i].m_guid.m_guid, members[i].m_priority, sessionKey, members[i].m_address);
comsat->SessionSetTalkerPriority(session, members[i].m_guid.m_guid, members[i].m_talkerPriority);
}
COMSATDATA* data = &s_comsatData[index];
data->m_members[0].m_guid.m_guid = self;
data->m_members[0].m_flags = selfFlags;
data->m_numMembers = count + 1;
for (uint32_t k = 1; k < data->m_numMembers; k++) {
data->m_members[k].m_guid = members[k - 1].m_guid;
data->m_members[k].m_flags = members[k - 1].m_flags;
}
for (int32_t i = 0; i < count; i++) {
uint32_t j;
for (j = 0; j < FriendList::s_friendList->GetNumIgnores(); j++) {
if (members[i].m_guid.m_guid == FriendList::s_friendList->GetIgnore(j)) {
break;
}
}
if (j < FriendList::s_friendList->GetNumIgnores()) {
comsat->MuteTalker(0, members[i].m_guid.m_guid, static_cast<ComSat::MuteSetting>(0));
continue;
}
for (uint32_t k = 0; k < FriendList::s_friendList->GetNumMutes(); k++) {
if (members[i].m_guid.m_guid == FriendList::s_friendList->GetIgnore(k)) {
comsat->MuteTalker(0, members[i].m_guid.m_guid, static_cast<ComSat::MuteSetting>(0));
}
}
}
if (s_voiceChatWasEnabled) {
switch (type) {
case 2:
CGChat::JoiningParty(false, 0);
s_voiceChatWasEnabled = 0;
break;
case 3:
CGChat::JoiningParty(true, 0);
s_voiceChatWasEnabled = 0;
break;
case 1:
CGChat::JoiningParty(true, 1);
s_voiceChatWasEnabled = 0;
break;
default:
break;
}
}
CGChat::VoiceSessionUpdate(type ? "" : name, type);
if (type == 2 || type == 3 || type == 1) {
Script_SendUniqueSignal(SCRIPT_EVENT_VOICE_STATUS_UPDATE);
} else {
Script_SendUniqueSignal(SCRIPT_EVENT_VOICE_CHANNEL_STATUS_UPDATE);
}
s_comsatDeviceLock.Leave();
}
// VERIFY: bea9cbd2 manual
// OFFSET: 0x007DEBF0
void VoiceSessionLeave(uint64_t talker, uint64_t session, int32_t type) {
s_comsatDeviceLock.Enter();
ComSat::Interface* comsat = ComSatThread::s_comsat;
if (!comsat) {
s_comsatDeviceLock.Leave();
return;
}
comsat->SessionRemove(session, talker);
comsat->SessionDestroy(session);
int32_t index;
for (index = 0; index < 32; index++) {
if (s_comsatData[index].m_sessionID == session || (type == s_comsatData[index].m_type && (type == 2 || type == 3))) {
break;
}
}
if (index < 32) {
if (s_currentSession == index) {
ComSatClient_LeaveSessionNotifyAll(index);
if (CGGameUI::m_initialized) {
FrameScript_SignalEvent(SCRIPT_EVENT_VOICE_LEFT_SESSION, nullptr);
}
s_currentSession = -1;
WOWGUID player = ClntObjMgrGetActivePlayer();
if (unk_D37D88.Ptr(static_cast<uint32_t>(player.m_guid), CHashKeyGUID(player.m_guid))) {
Script_SendUnitSignal(player, SCRIPT_EVENT_VOICE_STOP);
ComSatClient_SendEvent(SCRIPT_EVENT_VOICE_PLATE_STOP, player);
}
}
s_comsatData[index].m_sessionID = 0;
s_comsatData[index].m_name[0] = 0;
s_comsatData[index].m_type = 4;
s_comsatData[index].m_numMembers = 0;
}
if (CGGameUI::m_initialized) {
FrameScript_SignalEvent(SCRIPT_EVENT_VOICE_SESSIONS_UPDATE, nullptr);
}
s_comsatDeviceLock.Leave();
}