Inside3D!
     

Theoretical NetQuake "Reconnect" Cmd Fix

 
Post new topic   Reply to topic    Inside3d Forums Forum Index -> Programming Tutorials
View previous topic :: View next topic  
Author Message
Baker



Joined: 14 Mar 2006
Posts: 1538

PostPosted: Mon Jan 04, 2010 10:50 pm    Post subject: Theoretical NetQuake "Reconnect" Cmd Fix Reply with quote

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:
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...
Back to top
View user's profile Send private message
Team Xlink



Joined: 25 Jun 2009
Posts: 320

PostPosted: Mon Jan 04, 2010 11:04 pm    Post subject: Reply with quote

Very nice Very Happy

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.
_________________
Anonymous wrote:
if it works, it works. if it doesn't, HAHAHA!
Back to top
View user's profile Send private message
r00k



Joined: 13 Nov 2004
Posts: 483

PostPosted: Tue Jan 05, 2010 12:23 am    Post subject: Reply with quote

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.
Back to top
View user's profile Send private message
Eluan



Joined: 15 Jun 2008
Posts: 6
Location: Florianópolis, Brazil

PostPosted: Fri Apr 23, 2010 9:13 pm    Post subject: Reply with quote

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...)
Back to top
View user's profile Send private message Visit poster's website
Spike



Joined: 05 Nov 2004
Posts: 944
Location: UK

PostPosted: Fri Apr 23, 2010 9:24 pm    Post subject: Reply with quote

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.
_________________
What's a signature?
Back to top
View user's profile Send private message Visit poster's website
r00k



Joined: 13 Nov 2004
Posts: 483

PostPosted: Sat Apr 24, 2010 6:04 am    Post subject: Reply with quote

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:

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.
Back to top
View user's profile Send private message
Team Xlink



Joined: 25 Jun 2009
Posts: 320

PostPosted: Wed Apr 28, 2010 1:56 am    Post subject: Reply with quote

So all you have to do to make it 100% fool proof, and working is stuffcmd disconnnect before it trys to reconnect.
_________________
Anonymous wrote:
if it works, it works. if it doesn't, HAHAHA!
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    Inside3d Forums Forum Index -> Programming Tutorials All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2004 phpBB Group