aboutsummaryrefslogtreecommitdiff
path: root/launcher/minecraft/launch/MinecraftServerTarget.cpp
diff options
context:
space:
mode:
authorTrial97 <alexandru.tripon97@gmail.com>2023-08-05 18:21:09 +0300
committerTrial97 <alexandru.tripon97@gmail.com>2023-08-05 18:21:09 +0300
commit939a2d67ed75be714e9f3b1b918250d006b3860a (patch)
treec5700ba93652e26fc1f86235b1a278d90fd0ce91 /launcher/minecraft/launch/MinecraftServerTarget.cpp
parent6f7d901a1f5c02e0629e4bae9172c04bb81ce0d9 (diff)
parentae793f6cf11658c9abc5111e82d5ba7b3e6af127 (diff)
downloadPrismLauncher-939a2d67ed75be714e9f3b1b918250d006b3860a.tar.gz
PrismLauncher-939a2d67ed75be714e9f3b1b918250d006b3860a.tar.bz2
PrismLauncher-939a2d67ed75be714e9f3b1b918250d006b3860a.zip
Merge branch 'develop' of https://github.com/PrismLauncher/PrismLauncher into develop12
Signed-off-by: Trial97 <alexandru.tripon97@gmail.com>
Diffstat (limited to 'launcher/minecraft/launch/MinecraftServerTarget.cpp')
-rw-r--r--launcher/minecraft/launch/MinecraftServerTarget.cpp31
1 files changed, 12 insertions, 19 deletions
diff --git a/launcher/minecraft/launch/MinecraftServerTarget.cpp b/launcher/minecraft/launch/MinecraftServerTarget.cpp
index a3383ec0..e201efab 100644
--- a/launcher/minecraft/launch/MinecraftServerTarget.cpp
+++ b/launcher/minecraft/launch/MinecraftServerTarget.cpp
@@ -18,50 +18,43 @@
#include <QStringList>
// FIXME: the way this is written, it can't ever do any sort of validation and can accept total junk
-MinecraftServerTarget MinecraftServerTarget::parse(const QString &fullAddress) {
+MinecraftServerTarget MinecraftServerTarget::parse(const QString& fullAddress)
+{
QStringList split = fullAddress.split(":");
// The logic below replicates the exact logic minecraft uses for parsing server addresses.
// While the conversion is not lossless and eats errors, it ensures the same behavior
// within Minecraft and Prism Launcher when entering server addresses.
- if (fullAddress.startsWith("["))
- {
+ if (fullAddress.startsWith("[")) {
int bracket = fullAddress.indexOf("]");
- if (bracket > 0)
- {
+ if (bracket > 0) {
QString ipv6 = fullAddress.mid(1, bracket - 1);
QString port = fullAddress.mid(bracket + 1).trimmed();
- if (port.startsWith(":") && !ipv6.isEmpty())
- {
+ if (port.startsWith(":") && !ipv6.isEmpty()) {
port = port.mid(1);
split = QStringList({ ipv6, port });
- }
- else
- {
- split = QStringList({ipv6});
+ } else {
+ split = QStringList({ ipv6 });
}
}
}
- if (split.size() > 2)
- {
- split = QStringList({fullAddress});
+ if (split.size() > 2) {
+ split = QStringList({ fullAddress });
}
QString realAddress = split[0];
quint16 realPort = 25565;
- if (split.size() > 1)
- {
+ if (split.size() > 1) {
bool ok;
realPort = split[1].toUInt(&ok);
- if (!ok)
- {
+ if (!ok) {
realPort = 25565;
}
}
- return MinecraftServerTarget { realAddress, realPort };
+ return MinecraftServerTarget{ realAddress, realPort };
}