aboutsummaryrefslogtreecommitdiff
path: root/src/aopacket.cpp
diff options
context:
space:
mode:
authorCrystalwarrior <Varsash@Gmail.com>2022-07-30 19:42:22 +0300
committerGitHub <noreply@github.com>2022-07-30 18:42:22 +0200
commit7b88d4be954b415e069ee0d612e4df3793c61756 (patch)
treeeb8b93c10d369c0d0c5d6629e61dc661a0863481 /src/aopacket.cpp
parentcf91cc03f849bba498cd8d91505bf8db04f8b1f9 (diff)
Never send an unencoded packet to the server (#719)
* never send an unencoded packet to the server * oops * Improve packet validation to remove segfaults * WARNING: commit breaks connecting to servers, need help start fixing omniwhy caused by single fuckin string packets (AAAAAAAAAAAAAAAAA) * Fix failed connections to servers (Thanks to @Iuvee for helping me figure this out!) * Fix demoserver * who the fuck still uses goto Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> * ANOTHER GOTO???? Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> * braces Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> * good bot Update src/packet_distribution.cpp Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> * Fix demoserver harder * Improve demo logging * Fix memory leakage by deleting the packet Fix useless demoserver wait packet creation when none of that packet is used Co-authored-by: stonedDiscord <Tukz@gmx.de> Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> Co-authored-by: Salanto <62221668+Salanto@users.noreply.github.com>
Diffstat (limited to 'src/aopacket.cpp')
-rw-r--r--src/aopacket.cpp15
1 files changed, 6 insertions, 9 deletions
diff --git a/src/aopacket.cpp b/src/aopacket.cpp
index 8f4a6e36..4a89e980 100644
--- a/src/aopacket.cpp
+++ b/src/aopacket.cpp
@@ -1,18 +1,15 @@
#include "aopacket.h"
-AOPacket::AOPacket(QString p_packet_string)
-{
- QStringList packet_contents = p_packet_string.split("#");
-
- m_header = packet_contents.first();
- m_contents = packet_contents.mid(1, packet_contents.size()-2); // trims %
-}
-
QString AOPacket::to_string(bool encoded)
{
QStringList contents = m_contents;
- if (encoded)
+ if (encoded) {
escape(contents);
+ }
+ // Our packet is just the header by itself
+ if (contents.isEmpty()) {
+ return m_header + "#%";
+ }
return m_header + "#" + contents.join("#") + "#%";
}