summaryrefslogtreecommitdiff
path: root/console_cmds.c
diff options
context:
space:
mode:
authordarkvater <darkvater@openttd.org>2004-09-12 23:35:01 +0000
committerdarkvater <darkvater@openttd.org>2004-09-12 23:35:01 +0000
commit01dd0219d312060d64d714c566a5307f6b187057 (patch)
tree1cb3f0310e6977a2f58d828b00a1a70c173bce95 /console_cmds.c
parentec21a64c03c01dcf9fa842721766562262a49d66 (diff)
downloadopenttd-01dd0219d312060d64d714c566a5307f6b187057.tar.xz
(svn r229) -Fix: Some more const stuff fixed .(Tron)
-Fix: ParseConnectionString() function to parse network connection string: <IP>[:<PORT>][#<PLAY_AS] .
Diffstat (limited to 'console_cmds.c')
-rw-r--r--console_cmds.c32
1 files changed, 9 insertions, 23 deletions
diff --git a/console_cmds.c b/console_cmds.c
index 948bc7b03..8afcbe8d5 100644
--- a/console_cmds.c
+++ b/console_cmds.c
@@ -96,43 +96,29 @@ DEF_CONSOLE_CMD(ConScrollToTile)
DEF_CONSOLE_CMD(ConNetworkConnect)
{
- byte * b;
- byte * ip = NULL;
- byte * port = NULL;
- byte * player = NULL;
- byte c;
+ byte * ip;
+ const byte *port = NULL;
+ const byte *player = NULL;
uint16 rport;
if (argc<2) return NULL;
- b = argv[1];
+ ip = argv[1];
rport = _network_server_port;
- c = 0;
- ip = b;
- while (b[c] != 0) {
- if (((char)b[c]) == '#') {
- player = &b[c+1];
- b[c] = 0;
- }
- if (((char)b[c]) == ':') {
- port = &b[c+1];
- b[c] = 0;
- }
- c++;
- }
+ ParseConnectionString(&player, &port, ip);
- IConsolePrintF(_iconsole_color_default,"Connecting to %s...",ip);
+ IConsolePrintF(_iconsole_color_default,"Connecting to %s...", ip);
if (player!=NULL) {
_network_playas = atoi(player);
- IConsolePrintF(_iconsole_color_default," player-no: %s",player);
+ IConsolePrintF(_iconsole_color_default," player-no: %s", player);
}
if (port!=NULL) {
rport = atoi(port);
- IConsolePrintF(_iconsole_color_default," port: %s",port);
+ IConsolePrintF(_iconsole_color_default," port: %s", port);
}
- NetworkCoreConnectGame(b, rport);
+ NetworkCoreConnectGame(ip, rport);
return NULL;
}