diff options
author | Kae <80987908+Novaenia@users.noreply.github.com> | 2023-07-16 20:44:15 +1000 |
---|---|---|
committer | Kae <80987908+Novaenia@users.noreply.github.com> | 2023-07-16 20:44:15 +1000 |
commit | da098c7b4812408d1316b14b3b3f46d2ec7dce04 (patch) | |
tree | 6ec4606013ecad5b63f53f4c681cf501ad13f37a /source/game/StarWorldClient.cpp | |
parent | 4e44a4ed7566fbbc7248796423b822430205ad98 (diff) |
Support receiving SE voice data, resample per-speaker again because of positional delay
Diffstat (limited to 'source/game/StarWorldClient.cpp')
-rw-r--r-- | source/game/StarWorldClient.cpp | 31 |
1 files changed, 23 insertions, 8 deletions
diff --git a/source/game/StarWorldClient.cpp b/source/game/StarWorldClient.cpp index 272b5df..54d4651 100644 --- a/source/game/StarWorldClient.cpp +++ b/source/game/StarWorldClient.cpp @@ -795,20 +795,18 @@ void WorldClient::handleIncomingPackets(List<PacketPtr> const& packets) { m_damageManager->pushRemoteDamageRequest(damage->remoteDamageRequest); } else if (auto damage = as<DamageNotificationPacket>(packet)) { - auto& materialKind = damage->remoteDamageNotification.damageNotification.targetMaterialKind.utf8(); - const size_t prefixSize = SECRET_BROADCAST_PREFIX.size(); - const size_t signatureSize = Curve25519::SignatureSize; - const size_t dataSize = prefixSize + signatureSize; + std::string_view view(damage->remoteDamageNotification.damageNotification.targetMaterialKind.utf8()); + static const size_t FULL_SIZE = SECRET_BROADCAST_PREFIX.size() + Curve25519::SignatureSize; + static const std::string LEGACY_VOICE_PREFIX = "data\0voice\0"s; - if (materialKind.size() >= dataSize && materialKind.rfind(SECRET_BROADCAST_PREFIX, 0) != NPos) { + if (view.size() >= FULL_SIZE && view.rfind(SECRET_BROADCAST_PREFIX, 0) != NPos) { // this is actually a secret broadcast!! if (auto player = m_entityMap->get<Player>(damage->remoteDamageNotification.sourceEntityId)) { if (auto publicKey = player->getSecretPropertyView(SECRET_BROADCAST_PUBLIC_KEY)) { if (publicKey->utf8Size() == Curve25519::PublicKeySize) { - std::string_view broadcast(materialKind); - auto signature = broadcast.substr(prefixSize, signatureSize); + auto signature = view.substr(SECRET_BROADCAST_PREFIX.size(), Curve25519::SignatureSize); - auto rawBroadcast = broadcast.substr(dataSize); + auto rawBroadcast = view.substr(FULL_SIZE); if (Curve25519::verify( (uint8_t const*)signature.data(), (uint8_t const*)publicKey->utf8Ptr(), @@ -821,6 +819,23 @@ void WorldClient::handleIncomingPackets(List<PacketPtr> const& packets) { } } } + else if (view.size() > 75 && view.rfind(LEGACY_VOICE_PREFIX, 0) != NPos) { + // this is a StarExtensions voice packet + // (remove this and stop transmitting like this once most SE features are ported over) + if (auto player = m_entityMap->get<Player>(damage->remoteDamageNotification.sourceEntityId)) { + if (auto publicKey = player->effectsAnimator()->globalTagPtr("\0SE_VOICE_SIGNING_KEY"s)) { + auto rawData = view.substr(75); + if (m_broadcastCallback && Curve25519::verify( + (uint8_t const*)view.data() + LEGACY_VOICE_PREFIX.size(), + (uint8_t const*)publicKey->utf8Ptr(), + (void*)rawData.data(), + rawData.size() + )) { + m_broadcastCallback(player, "Voice\0"s + rawData); + } + } + } + } else { m_damageManager->pushRemoteDamageNotification(damage->remoteDamageNotification); } |