Merge branch 'master' into jgrpp

# Conflicts:
#	src/lang/simplified_chinese.txt
#	src/network/core/tcp_content.cpp
#	src/network/core/udp.cpp
#	src/network/network_server.cpp
#	src/saveload/linkgraph_sl.cpp
#	src/table/gameopt_settings.ini
This commit is contained in:
Jonathan G Rennison
2021-04-25 01:23:38 +01:00
96 changed files with 250 additions and 2653 deletions

View File

@@ -472,6 +472,36 @@ static void CheckPauseOnJoin()
CheckPauseHelper(NetworkHasJoiningClient(), PM_PAUSED_JOIN);
}
/**
* Converts a string to ip/port
* Format: IP:port
*
* connection_string will be re-terminated to separate out the hostname, port will
* be set to the port strings given by the user, inside the memory area originally
* occupied by connection_string.
*/
void ParseConnectionString(const char **port, char *connection_string)
{
bool ipv6 = (strchr(connection_string, ':') != strrchr(connection_string, ':'));
for (char *p = connection_string; *p != '\0'; p++) {
switch (*p) {
case '[':
ipv6 = true;
break;
case ']':
ipv6 = false;
break;
case ':':
if (ipv6) break;
*port = p + 1;
*p = '\0';
break;
}
}
}
/**
* Converts a string to ip/port/company
* Format: IP:port#company
@@ -480,11 +510,10 @@ static void CheckPauseOnJoin()
* be set to the company and port strings given by the user, inside the memory area originally
* occupied by connection_string.
*/
void ParseConnectionString(const char **company, const char **port, char *connection_string)
void ParseGameConnectionString(const char **company, const char **port, char *connection_string)
{
bool ipv6 = (strchr(connection_string, ':') != strrchr(connection_string, ':'));
char *p;
for (p = connection_string; *p != '\0'; p++) {
for (char *p = connection_string; *p != '\0'; p++) {
switch (*p) {
case '[':
ipv6 = true;
@@ -622,7 +651,6 @@ void NetworkAddServer(const char *b)
{
if (*b != '\0') {
const char *port = nullptr;
const char *company = nullptr;
char host[NETWORK_HOSTNAME_LENGTH];
uint16 rport;
@@ -631,7 +659,7 @@ void NetworkAddServer(const char *b)
strecpy(_settings_client.network.connect_to_ip, b, lastof(_settings_client.network.connect_to_ip));
rport = NETWORK_DEFAULT_PORT;
ParseConnectionString(&company, &port, host);
ParseConnectionString(&port, host);
if (port != nullptr) rport = atoi(port);
NetworkUDPQueryServer(NetworkAddress(host, rport), true);