MCPcopy Create free account
hub / github.com/BohemiaInteractive/CWR / clientReceive

Function clientReceive

engine/Poseidon/Network/NetTransportNet.cpp:989–1126  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

987 SendMsg(const_cast<BYTE*>(pkt.data()), static_cast<int>(pkt.size()), msgID, NMFHighPriority);
988 });
989
990 SetNetTransportClientVoiceSenderId([c]() { return c; }, static_cast<uint32_t>(playerNo));
991
992 LOG_INFO(Network, "VoN client initialized (player={})", playerNo);
993 return true;
994}
995
996bool NetClient::IsVoicePlaying(int player)
997{
998 PumpVoiceSpeakers();
999 auto found = _vonSpeakers.find(static_cast<uint32_t>(player));
1000 return found != _vonSpeakers.end() && found->second && found->second->active && found->second->level > 0.001f;
1001}
1002
1003bool NetClient::IsVoiceRecording()
1004{
1005 auto* c = _vonSystem.client();
1006 return c && c->isTransmitting();
1007}
1008
1009void NetClient::GetVoiceSpeakers(AutoArray<NetVoiceSpeakerInfo, Poseidon::Foundation::MemAllocSA>& speakers)
1010{
1011 PumpVoiceSpeakers();
1012 for (auto& [player, speaker] : _vonSpeakers)
1013 {
1014 if (!speaker)
1015 {
1016 continue;
1017 }
1018 NetVoiceSpeakerInfo info;
1019 info.player = static_cast<int>(player);
1020 const auto channel = _vonSpeakerChannels.find(player);
1021 info.channel = channel != _vonSpeakerChannels.end() ? static_cast<int>(channel->second)
1022 : static_cast<int>(VoNChatChannel::Global);
1023 info.active = speaker->active && speaker->level > 0.001f;
1024 info.level = speaker->level;
1025 speakers.Add(info);
1026 }
1027}
1028
1029void NetClient::PumpVoiceSpeakers()
1030{
1031 auto* c = _vonSystem.client();
1032 if (!c)
1033 return;
1034
1035 DWORD now = GlobalTickCount();
1036 if (_lastVoicePumpTime != 0 && now - _lastVoicePumpTime < 15)
1037 return;
1038 _lastVoicePumpTime = now;
1039
1040 for (auto& [ch, spk] : _vonSpeakers)
1041 {
1042 if (!spk)
1043 continue;
1044
1045 const auto channel = _vonSpeakerChannels.find(ch);
1046 spk->setChannel(channel != _vonSpeakerChannels.end() ? channel->second : VoNChatChannel::Global);

Callers

nothing calls this directly

Calls 13

mergeMessageListFunction · 0.85
getLengthMethod · 0.80
getFlagsMethod · 0.80
getChannelIdMethod · 0.80
getSerialMethod · 0.80
insertReceivedMethod · 0.80
getTimeMethod · 0.45
getDataMethod · 0.45
enterSndMethod · 0.45
leaveSndMethod · 0.45
enterRcvMethod · 0.45
NotNullMethod · 0.45

Tested by

no test coverage detected