Theoretical NetQuake "Reconnect" Cmd Fix

Post tutorials on how to do certain tasks within game or engine code here.
Post Reply
Baker
Posts: 3666
Joined: Tue Mar 14, 2006 5:15 am

Theoretical NetQuake "Reconnect" Cmd Fix

Post by Baker »

The reconnect command is broken in original Quake.

Something back in 2007 I discovered about DarkPlaces when playing some FFA with scar3crow, LordHavoc and others checking out new DP features LordHavoc had added at the time was that the "reconnect" command works in DarkPlaces.

In DarkPlaces if you somehow get disconnected from a server, you can type "reconnect" instead of "connect xx.xx.xxx.xx" or "connect whatever.server.com:ppppp".

R00k wrote a fixed "reconnect" command for NetQuake within the last few days:

Code: Select all

void Host_Reconnect_f (void)
{		
	extern char server_name[MAX_QPATH];
	char host[MAX_QPATH];

	if ((!sv.active) && (cls.state == ca_disconnected))//Clients that get booted can type reconnect.
	{
		Q_strncpyz(host, va("%s:%u\n",server_name,net_hostport), sizeof(host));
		if (server_name[0])
		{
			cls.demonum = -1;		

			if (cls.demoplayback)
			{
				CL_StopPlayback ();
				CL_Disconnect ();
			}

			Con_Printf("reconnecting to %s...\n",server_name);
			CL_EstablishConnection(host);
		}
		else
			Con_Printf("No server connection previously established this session.\n");
	}

	SCR_BeginLoadingPlaque ();
	cls.signon = 0;
}
I haven't tested it, it looks like R00k has given it some tests.

The above code appears to be geared towards ip:port supporting clients (i.e. ProQuake, Qrack, JoeQuake and any other clients that a "connect quake.myserver.com:26005" would work in.

R00k notes:
R00k wrote:I had to add 2 things, the latter SCR_Begin.. and cls.signon as this code was called by a stuffcmd by the server. Yes the server underhandedly tells each client to "automatically" type reconnect via level change (wow thats a hack). Thats like banning people by stuffing a command "disconnect" but that above code works now. With out the last two lines, movements carried over from map to map...
Team Xlink
Posts: 368
Joined: Thu Jun 25, 2009 4:45 am
Location: Michigan

Post by Team Xlink »

Very nice :D

I was wondering why the reconnect command never seemed to work, now I know that it is actually "broken".

I have made a a modified one for engines that don't have the :ipport support, based off of R00k's code from above. I will upload it after I do a special case test.
r00k
Posts: 1111
Joined: Sat Nov 13, 2004 10:39 pm

Post by r00k »

There still is a slight loophole, when online this function tells your client to wait for signon, and the server will reinit it's login process, because in netQuake the server normally does this via a stuffcmd instead of an svc you cannot disable or alter the way its executed from the console when connected online for the normal functionality to work. Whats this mean? if u disconnect 1st, then type reconnect it works. if you type reconnect while still connected it just sits at console, like normally bugged quake, waiting for the server to resend its signons. Basically your stuck waiting for a reload or map change.
Eluan
Posts: 10
Joined: Sun Jun 15, 2008 9:03 am
Location: Florianópolis, Brazil
Contact:

Post by Eluan »

Err... That's because "reconnect" was never meant to retry a lost connection. I'd say that the cleanest way to have the functionality you guys want is to encapsulate it in another cmd, not reconnect.

(You can also always check if the command was sent by the server or typed at the console, but...)
Spike
Posts: 2914
Joined: Fri Nov 05, 2004 3:12 am
Location: UK
Contact:

Post by Spike »

so long as 'disconnect; reconnect' works.
But yeah, might be better to check the svc directly, then users can't mess stuff up so easily.

or perhaps add a small timeout.
r00k
Posts: 1111
Joined: Sat Nov 13, 2004 10:39 pm

Post by r00k »

ya disconnect;reconnect is the best way.
reconnect just waits for a new signon
i couldnt think of a new name fitting, besides relogin and that sounded stupid so I just left it as is. if you get disconnected for whatever reason and the client didnt crash just type reconnect.
if you need to restart your settings and not the client use disconnect;reconnect.

Code: Select all

void Host_Reconnect_f (void)
{		
	extern char server_name[MAX_QPATH];
	char host[MAX_QPATH];

	SCR_BeginLoadingPlaque ();
	cls.signon = 0;

	if (!sv.active)
	{
		if (cls.state == ca_disconnected)
		{
			Q_strncpyz(host, va("%s:%u\n",server_name,net_hostport), sizeof(host));
			if (server_name[0])
			{
				Con_Printf("reconnecting to %s...\n",server_name);
				CL_EstablishConnection(host);
			}
			else
				Con_Printf("No server connection previously established this session.\n");
		}
	}
}
the svc sends it to the client as a stuffcmd so the check is comming from the command buffer same as if the client typed it in console.
Team Xlink
Posts: 368
Joined: Thu Jun 25, 2009 4:45 am
Location: Michigan

Post by Team Xlink »

So all you have to do to make it 100% fool proof, and working is stuffcmd disconnnect before it trys to reconnect.
Post Reply