Changeset 7254 in orxonox.OLD for branches/preferences/src/orxonox.cc
- Timestamp:
- Mar 29, 2006, 4:50:51 PM (18 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/preferences/src/orxonox.cc
r7251 r7254 68 68 SHELL_COMMAND(restart, Orxonox, restart); 69 69 70 REGISTER_ARG_FLAG( s, server, "game", "isServer", "Start Orxonox as Game Server", "1" ); 71 REGISTER_ARG_ARG( p, port, "game", "port", "Port to use", "port" ); 70 REGISTER_ARG_FLAG( l, license, "misc", "showLicenseAndExit", "Prints the licence and exit", "1" ); 71 REGISTER_ARG_FLAG( c, client, "game", "gameType", "Connect to Server (-H)", "multiplayer_client" ); 72 REGISTER_ARG_FLAG( s, server, "game", "gameType", "Start Orxonox as Game Server", "multiplayer_server" ); 73 REGISTER_ARG_ARG( H, host, "game", "host", "Host to connect to", "host"); 74 REGISTER_ARG_ARG( p, port, "game", "port", "Port to use", "port" ); 75 REGISTER_ARG_FLAG( g, gui, "game", "showGui", "starts the orxonox with the configuration GUI", "1"); 72 76 73 77 /** … … 408 412 prefs.parse(argc, argv); 409 413 410 int i; 411 for(i = 1; i < argc; ++i) 412 { 413 if( !strcmp( "--help", argv[i]) || !strcmp("-h", argv[i])) 414 return showHelp(argc, argv); 415 else if(!strcmp( "--gui", argv[i]) || !strcmp("-g", argv[i])) 416 showGui = true; 417 else if(!strcmp( "--client", argv[i]) || !strcmp("-c", argv[i])) 418 return startNetworkOrxonox(argc, argv); 419 else if(!strcmp( "--server", argv[i]) || !strcmp("-s", argv[i])) 420 return startNetworkOrxonox(argc, argv); 421 else if(!strcmp( "--license", argv[i]) || !strcmp("-l", argv[i])) 422 return PRINT(0)(ORXONOX_LICENSE_SHORT); 423 } 424 414 if ( Preferences::getInstance()->getString("misc", "showLicenseAndExit", "") == "1" ) 415 { 416 PRINT(0)(ORXONOX_LICENSE_SHORT); 417 return 0; 418 } 419 420 if( Preferences::getInstance()->getString("game", "showGui", "") == "1" ) 421 showGui = true; 422 else if( Preferences::getInstance()->getString( "game", "gameType", "" ) == "multiplayer_server" || 423 Preferences::getInstance()->getString( "game", "gameType", "" ) == "multiplayer_client" ) 424 return startNetworkOrxonox(argc, argv); 425 425 426 return startOrxonox(argc, argv, NULL, -1); 426 427 return 0; 427 428 } 428 429 430 431 int showHelp(int argc, char** argv)432 {433 PRINT(0)("Orxonox Version %s\n", PACKAGE_VERSION);434 PRINT(0)(" Starts Orxonox - The most furious 3D Action Game :)\n");435 PRINT(0)("\n");436 PRINT(0)("Common options:\n");437 PRINT(0)(" -g, --gui starts the orxonox with the configuration GUI \n");438 PRINT(0)(" -h, --help shows this help\n");439 PRINT(0)("\n");440 PRINT(0)("Network options:\n");441 PRINT(0)(" -s, --server [port] starts Orxonox and listens on the [port] for players\n");442 PRINT(0)(" -c, --client [hostname] [port] starts Orxonox as a Client\n");443 PRINT(0)(" -c, --client [ip address] [port] starts Orxonox as a Client\n");444 PRINT(0)("\n");445 PRINT(0)("Other options:\n");446 PRINT(0)(" --license prints the licence and exit\n\n");447 PRINT(0)("\n");448 449 // {450 // Gui* gui = new Gui(argc, argv);451 // gui->printHelp();452 // delete gui;453 // }454 }455 456 429 457 430 … … 465 438 { 466 439 467 int i; 468 for(i = 0; i < argc; ++i ) 469 { 470 if( !strcmp( "--client", argv[i]) || !strcmp("-c", argv[i])) 440 std::string gameType = Preferences::getInstance()->getString( "game", "gameType", "" ); 441 442 if ( gameType == "multiplayer_client" ) 443 { 444 int port = Preferences::getInstance()->getInt( "game", "port", DEFAULT_ORXONOX_PORT ); 445 std::string host = Preferences::getInstance()->getString( "game", "host", "" ); 446 447 if ( host == "" ) 471 448 { 472 if( argc <= (i+2)) 473 { 474 printf(" Wrong arguments try following notations:\n"); 475 printf(" --client [server ip address] [port number]\n"); 476 printf(" --client [dns name] [port number]\n"); 477 return 0; 478 } 479 480 const char* name = argv[i+1]; 481 int port = atoi(argv[i+2]); 482 printf("Starting Orxonox as client: connecting to %s, on port %i\n", name, port); 483 484 startOrxonox(argc, argv, name, port); 449 printf("You need to specify a host to connect to ( -H <host> )\n"); 450 return 1; 485 451 } 486 else if( !strcmp( "--server", argv[i]) || !strcmp("-s", argv[i])) 487 { 488 if( argc <= (i+1)) 489 { 490 printf(" Wrong arguments try following notations:\n"); 491 printf(" --server [port number]\n"); 492 return 0; 493 } 494 495 int port = atoi(argv[i+1]); 496 printf("Starting Orxonox as server, listening on port %i\n", port); 497 498 startOrxonox(argc, argv, NULL, port); 499 } 452 453 printf("Starting Orxonox as client: connecting to %s, on port %i\n", host.c_str(), port); 454 455 startOrxonox(argc, argv, host.c_str(), port); 456 } 457 else if ( gameType == "multiplayer_server" ) 458 { 459 int port = Preferences::getInstance()->getInt( "game", "port", DEFAULT_ORXONOX_PORT ); 460 461 printf("Starting Orxonox as server: listening on port %i\n", port); 462 463 startOrxonox(argc, argv, NULL, port); 500 464 } 501 465 }
Note: See TracChangeset
for help on using the changeset viewer.