From c5bf72393dc08f045f5935099e1ab447555a5521 Mon Sep 17 00:00:00 2001 From: Rafael Barreto Date: Mon, 1 Nov 2010 20:06:00 +0000 Subject: [PATCH] bug fixes: browse connection git-svn-id: svn://svn.code.sf.net/p/actiongame/code/trunk/ac@5798 e016b1c5-ed68-44aa-a2f7-31cac88cffde --- source/src/client.cpp | 6 ++++-- source/src/main.cpp | 6 +++--- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/source/src/client.cpp b/source/src/client.cpp index a5c237cf..bd74b3b1 100644 --- a/source/src/client.cpp +++ b/source/src/client.cpp @@ -61,18 +61,20 @@ void abortconnect() void connectserv_(const char *servername, const char *serverport = NULL, const char *password = NULL, int role = CR_DEFAULT) { + const char *defaultport = "28763"; + if (!serverport) serverport = defaultport; extern void enddemoplayback(); if(watchingdemo) enddemoplayback(); + if(connpeer) { conoutf(_("aborting connection attempt")); abortconnect(); } - connectrole = role; copystring(clientpassword, password ? password : ""); - ENetAddress address; + int p = 0; if(serverport && serverport[0]) p = atoi(serverport); address.port = p > 0 ? p : CUBE_DEFAULT_SERVER_PORT; diff --git a/source/src/main.cpp b/source/src/main.cpp index de384327..e844757c 100644 --- a/source/src/main.cpp +++ b/source/src/main.cpp @@ -1098,7 +1098,7 @@ int main(int argc, char **argv) case 'e': initscript = &argv[i][2]; break; default: conoutf("\f3unknown commandline option: -%c", argv[i][1]); } - else if(!strncmp(argv[i], "assaultcube://", 13)) // browser direct connection + else if(!strncmp(argv[i], "assaultcube://", 14)) // browser direct connection { const char *c = &argv[i][14], *p = c; int len = 0; @@ -1108,8 +1108,8 @@ int main(int argc, char **argv) strncpy(servername,p,len); servername[len] = '\0'; direct_connect = true; - c++; - if (*c!='?') continue; + if (*c) c++; + if (!*c || *c!='?') continue; c++; if (!strncmp(c, "port=", 5)) {