camino-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Camino-devel] camino/src main.cpp


From: Philippe Fremy
Subject: [Camino-devel] camino/src main.cpp
Date: Mon, 17 Feb 2003 16:33:18 -0500

CVSROOT:        /cvsroot/camino
Module name:    camino
Changes by:     Philippe Fremy <address@hidden> 03/02/17 16:33:18

Modified files:
        src            : main.cpp 

Log message:
        It is now possible to launch the server and the client automatically 
from the
        command line.
        
        Arguments available:
        --port
        --player
        --host
        
        --server: to launch a server.
        
        If --server is not present, launches a client. port and host are set 
correctly
        to local default host.

Patches:
Index: camino/src/main.cpp
diff -u camino/src/main.cpp:1.3 camino/src/main.cpp:1.4
--- camino/src/main.cpp:1.3     Sun Jan 26 11:49:22 2003
+++ camino/src/main.cpp Mon Feb 17 16:33:17 2003
@@ -2,7 +2,7 @@
 **
 ** Camino
 **
-** Version : $Id: main.cpp,v 1.3 2003/01/26 16:49:22 pfremy Exp $
+** Version : $Id: main.cpp,v 1.4 2003/02/17 21:33:17 pfremy Exp $
 **
 ** Author(s) : Philippe Fremy, Pascal Audoux
 ** Creation : 14/01/2003
@@ -27,18 +27,65 @@
 #include <time.h>
 // include files for QT
 #include <qapplication.h>
+#include <qstring.h>
+#include <qobject.h>
 // application specific include files
 #include "client/ClientInterface.h"
+#include "server/CaminoServer.h"
+#include "server/ServerWidget.h"
 
 int main( int argc, char **argv )
 {
        srand( time( 0 ) );
        QApplication app( argc, argv );
 
-       ClientInterface game;
-       //game.showMaximized();
-       app.setMainWidget( &game );
-       game.show();
+       QString hostName = "localhost";
+       QString playerName = "Phil";
+       int port = 6789;
+       bool clientArgPassed = false;
+       bool startServer = false;
+
+       for( int i=1; i<argc; i++ ) {
+           if ( QString( argv[i] ) == "--host" && i+1 < argc ) {
+               clientArgPassed = true;
+               ++i;
+               continue;
+           }
+           if ( QString( argv[i] ) == "--port" && i+1 < argc ) {
+               port = QString( argv[ i + 1 ] ).toInt();
+               clientArgPassed = true;
+               ++i;
+               continue;
+           }
+           if ( QString( argv[i] ) == "--player" && i+1 < argc ) {
+               playerName = argv[ i + 1 ];
+               clientArgPassed = true;
+               ++i;
+               continue;
+           }
+           if ( QString( argv[i] ) == "--server") {
+               startServer = true;
+               continue;
+           }
+       }
+       
+
+       if ( startServer ) clientArgPassed = false;
+       ClientInterface clientWindow(  clientArgPassed, hostName, port, 
playerName );
+       //clientWindow.showMaximized();
+       app.setMainWidget( &clientWindow );
+       clientWindow.show();
+
+       if ( startServer == true ) {
+               clientWindow.hide();
+           CaminoServer * server = new CaminoServer( port, 2 );
+           ServerWidget * serverWidget = new ServerWidget( server );
+           serverWidget->hide();
+
+           QObject::connect(  server, SIGNAL( sig_msg( NetMsgSubtype, QString, 
QString ) ), 
+                             serverWidget, SLOT( slot_appendMsg( 
NetMsgSubtype, QString, QString ) ) );
+           clientWindow.slot_serverStarted( server, serverWidget );
+       }
 
        return app.exec();
 }




reply via email to

[Prev in Thread] Current Thread [Next in Thread]