summaryrefslogtreecommitdiff
path: root/src/network/network.cpp
diff options
context:
space:
mode:
authorDarkvater <Darkvater@openttd.org>2007-01-16 23:01:06 +0000
committerDarkvater <Darkvater@openttd.org>2007-01-16 23:01:06 +0000
commit4b3cbf1a14d0ffd43839428cbe38a90ad192dde8 (patch)
tree700c3ad448c00a1362caf7d0b2195d5ec5c874fe /src/network/network.cpp
parent5696dfef94ee719fbf23de07a87034e1950544a6 (diff)
downloadopenttd-4b3cbf1a14d0ffd43839428cbe38a90ad192dde8.tar.xz
(svn r8168) -Regression (r6783): ParseConnectionstring didn't use the port parameter if a player was also specified. (both IP#Player:Port and IP:Port#Player btw)
Diffstat (limited to 'src/network/network.cpp')
-rw-r--r--src/network/network.cpp29
1 files changed, 15 insertions, 14 deletions
diff --git a/src/network/network.cpp b/src/network/network.cpp
index 124409e3d..0211aebd2 100644
--- a/src/network/network.cpp
+++ b/src/network/network.cpp
@@ -525,24 +525,25 @@ unsigned long NetworkResolveHost(const char *hostname)
return ip;
}
-// Converts a string to ip/port/player
-// Format: IP#player:port
-//
-// connection_string will be re-terminated to seperate out the hostname, and player and port will
-// be set to the player and port strings given by the user, inside the memory area originally
-// occupied by connection_string.
+/** Converts a string to ip/port/player
+ * Format: IP#player:port
+ *
+ * connection_string will be re-terminated to seperate out the hostname, and player and port will
+ * be set to the player and port strings given by the user, inside the memory area originally
+ * occupied by connection_string. */
void ParseConnectionString(const char **player, const char **port, char *connection_string)
{
char *p;
for (p = connection_string; *p != '\0'; p++) {
- if (*p == '#') {
- *p = '\0';
- *player = ++p;
- while (IsValidChar(*p, CS_NUMERAL)) p++;
- if (*p == '\0') break;
- } else if (*p == ':') {
- *port = p + 1;
- *p = '\0';
+ switch (*p) {
+ case '#':
+ *player = p + 1;
+ *p = '\0';
+ break;
+ case ':':
+ *port = p + 1;
+ *p = '\0';
+ break;
}
}
}