diff options
author | Kae <80987908+Novaenia@users.noreply.github.com> | 2023-08-02 14:43:49 +1000 |
---|---|---|
committer | Kae <80987908+Novaenia@users.noreply.github.com> | 2023-08-02 14:43:49 +1000 |
commit | 856e93be3f1a443db2679ad7db9f6890a9b4d936 (patch) | |
tree | 196336b2f821b8c4b07d1c15925978cec5700bff | |
parent | b318e981e3f454941d3de07a018adb485238fbb9 (diff) |
Skip packet compression on Voice packets
cause 99% of the data is already compressed by Opus
-rw-r--r-- | source/client/StarClientApplication.cpp | 2 | ||||
-rw-r--r-- | source/game/StarWorldClient.cpp | 5 | ||||
-rw-r--r-- | source/game/StarWorldClient.hpp | 2 |
3 files changed, 6 insertions, 3 deletions
diff --git a/source/client/StarClientApplication.cpp b/source/client/StarClientApplication.cpp index efbdcad..9213d0e 100644 --- a/source/client/StarClientApplication.cpp +++ b/source/client/StarClientApplication.cpp @@ -921,7 +921,7 @@ void ClientApplication::updateRunning(float dt) { std::string_view signatureView((char*)signature.data(), signature.size()); std::string_view audioDataView(voiceData.ptr(), voiceData.size()); auto broadcast = strf("data\0voice\0{}{}"s, signatureView, audioDataView); - worldClient->sendSecretBroadcast(broadcast, true); + worldClient->sendSecretBroadcast(broadcast, true, false); // Already compressed by Opus. } if (auto mainPlayer = m_universeClient->mainPlayer()) { auto localSpeaker = m_voice->localSpeaker(); diff --git a/source/game/StarWorldClient.cpp b/source/game/StarWorldClient.cpp index f9ad833..24199c3 100644 --- a/source/game/StarWorldClient.cpp +++ b/source/game/StarWorldClient.cpp @@ -2013,7 +2013,7 @@ void WorldClient::connectWire(WireConnection const& output, WireConnection const m_outgoingPackets.append(make_shared<ConnectWirePacket>(output, input)); } -bool WorldClient::sendSecretBroadcast(StringView broadcast, bool raw) { +bool WorldClient::sendSecretBroadcast(StringView broadcast, bool raw, bool compress) { if (!inWorld() || !m_mainPlayer || !m_mainPlayer->getSecretPropertyView(SECRET_BROADCAST_PUBLIC_KEY)) return false; @@ -2030,6 +2030,9 @@ bool WorldClient::sendSecretBroadcast(StringView broadcast, bool raw) { dmg.targetMaterialKind = raw ? broadcast : strf("{}{}{}", SECRET_BROADCAST_PREFIX, StringView((char*)&signature, sizeof(signature)), broadcast); dmg.position = m_mainPlayer->position(); + if (!compress) + damageNotification->setCompressionMode(PacketCompressionMode::Disabled); + m_outgoingPackets.emplace_back(move(damageNotification)); return true; } diff --git a/source/game/StarWorldClient.hpp b/source/game/StarWorldClient.hpp index 0adbef6..d816117 100644 --- a/source/game/StarWorldClient.hpp +++ b/source/game/StarWorldClient.hpp @@ -155,7 +155,7 @@ public: // Functions for sending broadcast messages to other players that can receive them, // on completely vanilla servers by smuggling it through a DamageNotification. // It's cursed as fuck, but it works. - bool sendSecretBroadcast(StringView broadcast, bool raw = false); + bool sendSecretBroadcast(StringView broadcast, bool raw = false, bool compress = true); bool handleSecretBroadcast(PlayerPtr player, StringView broadcast); List<ChatAction> pullPendingChatActions(); |