- Timestamp:
- Mar 29, 2006, 4:50:51 PM (19 years ago)
- Location:
- branches/preferences/src
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/preferences/src/defs/globals.h
r6998 r7254 27 27 #define DEFAULT_DATA_DIR DATADIR "/orxonox/" 28 28 #define DEFAULT_DATA_DIR_CHECKFILE "data.oxd" 29 30 #define DEFAULT_ORXONOX_PORT 9999 29 31 30 32 // Defines all the Sections of the Config (in Gui and orxonox) -
branches/preferences/src/lib/parser/preferences/cmd_line_prefs_reader.cc
r7253 r7254 71 71 cbd->parser->showHelp(); 72 72 return true; 73 case ID_LICENSE:74 PRINT(0)(ORXONOX_LICENSE_SHORT);75 return true;76 73 } 77 74 78 if ( entry.id >= ID_ LAST && entry.id - ID_LAST< regArgs.size() )75 if ( entry.id >= ID_PREFS && entry.id - ID_PREFS < regArgs.size() ) 79 76 { 80 if ( regArgs[entry.id - ID_ LAST].value == "%arg%" )77 if ( regArgs[entry.id - ID_PREFS].value == "%arg%" ) 81 78 { 82 79 assert( argArgs.size() == 1 ); 83 80 84 81 cbd->iniEntries.push_back( IniEntry() ); 85 cbd->iniEntries.back().section = regArgs[entry.id - ID_ LAST].section;86 cbd->iniEntries.back().key = regArgs[entry.id - ID_ LAST].key;82 cbd->iniEntries.back().section = regArgs[entry.id - ID_PREFS].section; 83 cbd->iniEntries.back().key = regArgs[entry.id - ID_PREFS].key; 87 84 cbd->iniEntries.back().value = argArgs[0].getString(); 88 85 } … … 90 87 { 91 88 cbd->iniEntries.push_back( IniEntry() ); 92 cbd->iniEntries.back().section = regArgs[entry.id - ID_ LAST].section;93 cbd->iniEntries.back().key = regArgs[entry.id - ID_ LAST].key;94 cbd->iniEntries.back().value = regArgs[entry.id - ID_ LAST].value;89 cbd->iniEntries.back().section = regArgs[entry.id - ID_PREFS].section; 90 cbd->iniEntries.back().key = regArgs[entry.id - ID_PREFS].key; 91 cbd->iniEntries.back().value = regArgs[entry.id - ID_PREFS].value; 95 92 } 96 93 } … … 109 106 110 107 parser.add( ID_HELP, "help", 'h', 0, "", "Shows this help"); 111 parser.add( ID_LICENSE, "license", 'l', 0, "", "Prints the licence and exit");112 108 113 109 for ( int i = 0; i<regArgs.size(); i++ ) … … 115 111 if ( regArgs[i].value == "%arg%" ) 116 112 { 117 parser.add( ID_ LAST+ i, regArgs[i].longOption, regArgs[i].shortOption, 1, regArgs[i].argName, regArgs[i].help );113 parser.add( ID_PREFS + i, regArgs[i].longOption, regArgs[i].shortOption, 1, regArgs[i].argName, regArgs[i].help ); 118 114 } 119 115 else 120 116 { 121 parser.add( ID_ LAST+ i, regArgs[i].longOption, regArgs[i].shortOption, 0, "", regArgs[i].help );117 parser.add( ID_PREFS + i, regArgs[i].longOption, regArgs[i].shortOption, 0, "", regArgs[i].help ); 122 118 } 123 119 } -
branches/preferences/src/lib/parser/preferences/cmd_line_prefs_reader.h
r7253 r7254 9 9 #include "stdincl.h" 10 10 #include "debug.h" 11 #include "globals.h"12 11 13 12 #include "src/lib/parser/cmdline_parser/cmdline_parser.h" … … 43 42 ID_SET_INI = 1, 44 43 ID_HELP, 45 ID_LICENSE, 46 ID_LAST 44 ID_PREFS 47 45 }; 48 46 -
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 } -
branches/preferences/src/orxonox.h
r7250 r7254 57 57 // Start-up functions // 58 58 //////////////////////// 59 int showHelp(int argc, char** argv); 60 int showLicense(); 59 61 60 int startNetworkOrxonox(int argc, char** argv); 62 61 int startOrxonox(int argc, char** argv, const char* clientName, int port);
Note: See TracChangeset
for help on using the changeset viewer.