From: divverent Date: Fri, 3 Sep 2010 05:20:33 +0000 (+0000) Subject: added arg: connect-userinfo; works like this: "connect server password foobar" will... X-Git-Tag: xonotic-v0.1.0preview~230^2~50 X-Git-Url: http://de.git.xonotic.org/?p=xonotic%2Fdarkplaces.git;a=commitdiff_plain;h=e20a7791af80303078df78c93a261d291f3f0b19 added arg: connect-userinfo; works like this: "connect server password foobar" will connect to server, and add \password\foobar to the infostring (works to connect to FTEQW passworded servers) git-svn-id: svn://svn.icculus.org/twilight/trunk/darkplaces@10434 d7cf8633-e32d-0410-b094-e92efae38249 --- diff --git a/cl_main.c b/cl_main.c index 6ca122d1..f005cafd 100644 --- a/cl_main.c +++ b/cl_main.c @@ -407,7 +407,7 @@ CL_EstablishConnection Host should be either "local" or a net address ===================== */ -void CL_EstablishConnection(const char *host) +void CL_EstablishConnection(const char *host, int firstarg) { if (cls.state == ca_dedicated) return; @@ -434,7 +434,24 @@ void CL_EstablishConnection(const char *host) cls.connect_trying = true; cls.connect_remainingtries = 3; cls.connect_nextsendtime = 0; + + // only NOW, set connect_userinfo + if(firstarg >= 0) + { + int i; + *cls.connect_userinfo = 0; + for(i = firstarg; i+2 <= Cmd_Argc(); i += 2) + InfoString_SetValue(cls.connect_userinfo, sizeof(cls.connect_userinfo), Cmd_Argv(i), Cmd_Argv(i+1)); + } + else if(firstarg < -1) + { + // -1: keep as is (reconnect) + // -2: clear + *cls.connect_userinfo = 0; + } + M_Update_Return_Reason("Trying to connect..."); + // run several network frames to jump into the game quickly //if (sv.active) //{ diff --git a/client.h b/client.h index d9780164..2ab8079c 100644 --- a/client.h +++ b/client.h @@ -710,6 +710,9 @@ typedef struct client_static_s // password spectator name team skin topcolor bottomcolor rate noaim msg *ver *ip char userinfo[MAX_USERINFO_STRING]; + // extra user info for the "connect" command + char connect_userinfo[MAX_USERINFO_STRING]; + // video capture stuff capturevideostate_t capturevideo; } @@ -1334,7 +1337,7 @@ void CL_Locs_FindLocationName(char *buffer, size_t buffersize, vec3_t point); void CL_Shutdown (void); void CL_Init (void); -void CL_EstablishConnection(const char *host); +void CL_EstablishConnection(const char *host, int firstarg); void CL_Disconnect (void); void CL_Disconnect_f (void); diff --git a/host_cmd.c b/host_cmd.c index 3f9c56e8..d15a04ca 100644 --- a/host_cmd.c +++ b/host_cmd.c @@ -383,7 +383,7 @@ void Host_Map_f (void) strlcpy(level, Cmd_Argv(1), sizeof(level)); SV_SpawnServer(level); if (sv.active && cls.state == ca_disconnected) - CL_EstablishConnection("local:1"); + CL_EstablishConnection("local:1", -2); } /* @@ -420,7 +420,7 @@ void Host_Changelevel_f (void) strlcpy(level, Cmd_Argv(1), sizeof(level)); SV_SpawnServer(level); if (sv.active && cls.state == ca_disconnected) - CL_EstablishConnection("local:1"); + CL_EstablishConnection("local:1", -2); } /* @@ -454,7 +454,7 @@ void Host_Restart_f (void) strlcpy(mapname, sv.name, sizeof(mapname)); SV_SpawnServer(mapname); if (sv.active && cls.state == ca_disconnected) - CL_EstablishConnection("local:1"); + CL_EstablishConnection("local:1", -2); } /* @@ -475,7 +475,7 @@ void Host_Reconnect_f (void) // will still contain its IP address, so get the address... InfoString_GetValue(cls.userinfo, "*ip", temp, sizeof(temp)); if (temp[0]) - CL_EstablishConnection(temp); + CL_EstablishConnection(temp, -1); else Con_Printf("Reconnect to what server? (you have not connected to a server yet)\n"); return; @@ -530,7 +530,7 @@ void Host_Connect_f (void) // clear the rcon password, to prevent vulnerability by stuffcmd-ing a connect command if(rcon_secure.integer <= 0) Cvar_SetQuick(&rcon_password, ""); - CL_EstablishConnection(Cmd_Argv(1)); + CL_EstablishConnection(Cmd_Argv(1), 2); } @@ -1072,7 +1072,7 @@ void Host_Loadgame_f (void) // make sure we're connected to loopback if (sv.active && cls.state == ca_disconnected) - CL_EstablishConnection("local:1"); + CL_EstablishConnection("local:1", -2); } //============================================================================ diff --git a/netconn.c b/netconn.c index 3f0796e5..3de63949 100755 --- a/netconn.c +++ b/netconn.c @@ -1660,7 +1660,7 @@ static int NetConn_ClientParsePacket(lhnetsocket_t *mysocket, unsigned char *dat // update the server IP in the userinfo (QW servers expect this, and it is used by the reconnect command) InfoString_SetValue(cls.userinfo, sizeof(cls.userinfo), "*ip", addressstring2); // TODO: add userinfo stuff here instead of using NQ commands? - NetConn_WriteString(mysocket, va("\377\377\377\377connect\\protocol\\darkplaces 3\\protocols\\%s\\challenge\\%s", protocolnames, string + 10), peeraddress); + NetConn_WriteString(mysocket, va("\377\377\377\377connect\\protocol\\darkplaces 3\\protocols\\%s\\%schallenge\\%s", protocolnames, cls.connect_userinfo, string + 10), peeraddress); return true; } if (length == 6 && !memcmp(string, "accept", 6) && cls.connect_trying) @@ -1844,7 +1844,7 @@ static int NetConn_ClientParsePacket(lhnetsocket_t *mysocket, unsigned char *dat cls.qw_qport = qport.integer; // update the server IP in the userinfo (QW servers expect this, and it is used by the reconnect command) InfoString_SetValue(cls.userinfo, sizeof(cls.userinfo), "*ip", addressstring2); - NetConn_WriteString(mysocket, va("\377\377\377\377connect %i %i %i \"%s\"\n", 28, cls.qw_qport, atoi(string + 1), cls.userinfo), peeraddress); + NetConn_WriteString(mysocket, va("\377\377\377\377connect %i %i %i \"%s%s\"\n", 28, cls.qw_qport, atoi(string + 1), cls.userinfo, cls.connect_userinfo), peeraddress); return true; } if (length >= 1 && string[0] == 'j' && cls.connect_trying)