Implement proximity chat. Very raw at the moment

This commit is contained in:
haxi0
2026-03-09 16:04:58 +03:00
parent a195ac7172
commit 7b748a433d
26 changed files with 672 additions and 5 deletions
+36
View File
@@ -54,6 +54,7 @@
#include "PS3/Network/SonyVoiceChat.h"
#endif
#include "DLCTexturePack.h"
#include "VoiceChatManager.h"
#ifdef _WINDOWS64
#include "Xbox\Network\NetworkPlayerXbox.h"
@@ -4069,3 +4070,38 @@ ClientConnection::DeferredEntityLinkPacket::DeferredEntityLinkPacket(shared_ptr<
m_recievedTick = GetTickCount();
m_packet = packet;
}
void ClientConnection::handleVoiceChat(VoiceChatPacket *packet)
{
if (done) return;
if (packet == nullptr || packet->dataLength <= 0) return;
if (minecraft == nullptr || minecraft->level == nullptr) return;
// Don't play back our own voice
for (int i = 0; i < XUSER_MAX_COUNT; i++)
{
if (minecraft->localplayers[i] != nullptr && minecraft->localplayers[i]->entityId == packet->senderPlayerId)
{
return;
}
}
// Mark the sender as speaking in VoiceChatManager (centralized tracking)
VoiceChatManager::getInstance().markSpeaking(packet->senderPlayerId);
// Find the sender entity position for 3D audio
shared_ptr<Entity> senderEntity = minecraft->level->getEntity(packet->senderPlayerId);
double sx = 0, sy = 0, sz = 0;
if (senderEntity != nullptr)
{
sx = senderEntity->x;
sy = senderEntity->y;
sz = senderEntity->z;
}
// Route audio to VoiceChatManager for 3D playback
VoiceChatManager::getInstance().receiveVoiceData(
packet->senderPlayerId, sx, sy, sz,
(const unsigned char *)packet->audioData.data,
packet->dataLength);
}