src/tron/gCommandLineJumpStart.cpp

Go to the documentation of this file.
00001 /*
00002  
00003  *************************************************************************
00004  
00005  ArmageTron -- Just another Tron Lightcycle Game in 3D.
00006  Copyright (C) 2005  by Daniel Harple
00007  and the AA DevTeam (see the file AUTHORS(.txt) in the main source directory)
00008  
00009  **************************************************************************
00010  
00011  This program is free software; you can redistribute it and/or
00012  modify it under the terms of the GNU General Public License
00013  as published by the Free Software Foundation; either version 2
00014  of the License, or (at your option) any later version.
00015  
00016  This program is distributed in the hope that it will be useful,
00017  but WITHOUT ANY WARRANTY; without even the implied warranty of
00018  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00019  GNU General Public License for more details.
00020  
00021  You should have received a copy of the GNU General Public License
00022  along with this program; if not, write to the Free Software
00023  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
00024  
00025  ***************************************************************************
00026  
00027  */
00028 
00029 #include "gGame.h"
00030 #include "gCommandLineJumpStart.h"
00031 #include "gLogo.h"
00032 
00033 // *****************************************************************************
00034 // *
00035 // * gCommandLineJumpStartAnalyzer
00036 // *
00037 // *****************************************************************************
00038 // *****************************************************************************
00039 
00040 bool gCommandLineJumpStartAnalyzer::DoAnalyze( tCommandLineParser & parser )
00041 {
00042     if ( parser.GetOption( _raw, "--connect" ) )
00043     {
00044         _shouldConnect = true;
00045 
00046         return true;
00047     }
00048     else
00049     {
00050         _shouldConnect = false;
00051     }
00052 
00053     return false;
00054 }
00055 
00056 void gCommandLineJumpStartAnalyzer::DoHelp( std::ostream & s )
00057 {
00058     s << "--connect <server>[:<port>]  : connect directly to SERVER, skipping all menus. default PORT=4534\n";
00059 }
00060 
00061 void gCommandLineJumpStartAnalyzer::Connect()
00062 {
00063     tString server;
00064     tString port;
00065 
00066     ExtractConnectionInformation( _raw, server, port );
00067 
00068     nServerInfoRedirect connectTo( server, port.ToInt() );
00069 
00070     ConnectToServer( &connectTo );
00071 }
00072 
00073 // *****************************************************************************
00074 // *
00075 // * ExtractConnectionInformation()
00076 // *
00077 // * Accepted formats
00078 // *    - armagetronad://<server>[:<port>]
00079 // *    - <server>[:<port>]
00080 // *
00081 // *****************************************************************************
00087 // *****************************************************************************
00088 void ExtractConnectionInformation( tString &raw, tString &servername, tString &port )
00089 {
00090     // BUG: case sensitive
00091     if ( raw.StartsWith("armagetronad://") )
00092     {
00093         raw.RemoveSubStr(0, 15);
00094     }
00095 
00096     int portStart = strcspn( raw, ":" );
00097     // Is a port given?
00098     if ( portStart != raw.Len() - 1 )
00099     {
00100         servername = raw.SubStr( 0, portStart );
00101         port       = raw.SubStr( portStart + 1 );
00102     }
00103     else
00104     {
00105         servername = raw;
00106         port       = "4534";
00107     }
00108 }
00109 
00110 #ifdef MACOSX
00111 void AAURLHandlerConnect( nServerInfoBase * server )
00112 {
00113     gLogo::SetDisplayed(false);
00114     ConnectToServer( server );
00115 }
00116 #endif
00117 
00118 

Generated on Sat Mar 15 22:56:06 2008 for Armagetron Advanced by  doxygen 1.5.4