summaryrefslogtreecommitdiff
path: root/src/network/core/address.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/network/core/address.cpp')
-rw-r--r--src/network/core/address.cpp11
1 files changed, 8 insertions, 3 deletions
diff --git a/src/network/core/address.cpp b/src/network/core/address.cpp
index 113dae686..4c090c14a 100644
--- a/src/network/core/address.cpp
+++ b/src/network/core/address.cpp
@@ -414,17 +414,22 @@ void NetworkAddress::Listen(int socktype, SocketList *sockets)
}
/**
- * Convert a string containing either "hostname" or "hostname:ip" to a
- * ServerAddress, where the string can be postfixed with "#company" to
+ * Convert a string containing either "hostname", "hostname:port" or invite code
+ * to a ServerAddress, where the string can be postfixed with "#company" to
* indicate the requested company.
*
* @param connection_string The string to parse.
* @param default_port The default port to set port to if not in connection_string.
- * @param company Pointer to the company variable to set iff indicted.
+ * @param company Pointer to the company variable to set iff indicated.
* @return A valid ServerAddress of the parsed information.
*/
/* static */ ServerAddress ServerAddress::Parse(const std::string &connection_string, uint16 default_port, CompanyID *company_id)
{
+ if (StrStartsWith(connection_string, "+")) {
+ std::string_view invite_code = ParseCompanyFromConnectionString(connection_string, company_id);
+ return ServerAddress(SERVER_ADDRESS_INVITE_CODE, std::string(invite_code));
+ }
+
uint16 port = default_port;
std::string_view ip = ParseFullConnectionString(connection_string, port, company_id);
return ServerAddress(SERVER_ADDRESS_DIRECT, std::string(ip) + ":" + std::to_string(port));