Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 7254 in orxonox.OLD for branches


Ignore:
Timestamp:
Mar 29, 2006, 4:50:51 PM (19 years ago)
Author:
rennerc
Message:

option -l/—license is now handled in orxonox.cc

Location:
branches/preferences/src
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • branches/preferences/src/defs/globals.h

    r6998 r7254  
    2727#define   DEFAULT_DATA_DIR                 DATADIR "/orxonox/"
    2828#define   DEFAULT_DATA_DIR_CHECKFILE       "data.oxd"
     29
     30#define   DEFAULT_ORXONOX_PORT             9999
    2931
    3032// Defines all the Sections of the Config (in Gui and orxonox)
  • branches/preferences/src/lib/parser/preferences/cmd_line_prefs_reader.cc

    r7253 r7254  
    7171      cbd->parser->showHelp();
    7272      return true;
    73     case ID_LICENSE:
    74       PRINT(0)(ORXONOX_LICENSE_SHORT);
    75       return true;
    7673  }
    7774 
    78   if ( entry.id >= ID_LAST && entry.id - ID_LAST < regArgs.size() )
     75  if ( entry.id >= ID_PREFS && entry.id - ID_PREFS < regArgs.size() )
    7976  {
    80     if ( regArgs[entry.id - ID_LAST].value == "%arg%" )
     77    if ( regArgs[entry.id - ID_PREFS].value == "%arg%" )
    8178    {
    8279      assert( argArgs.size() == 1 );
    8380     
    8481      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;
    8784      cbd->iniEntries.back().value = argArgs[0].getString();
    8885    }
     
    9087    {
    9188      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;
    9592    }
    9693  }
     
    109106 
    110107  parser.add( ID_HELP, "help", 'h', 0, "", "Shows this help");
    111   parser.add( ID_LICENSE, "license", 'l', 0, "", "Prints the licence and exit");
    112108 
    113109  for ( int i = 0; i<regArgs.size(); i++ )
     
    115111    if ( regArgs[i].value == "%arg%" )
    116112    {
    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 );
    118114    }
    119115    else
    120116    {
    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 );
    122118    }
    123119  }
  • branches/preferences/src/lib/parser/preferences/cmd_line_prefs_reader.h

    r7253 r7254  
    99#include "stdincl.h"
    1010#include "debug.h"
    11 #include "globals.h"
    1211
    1312#include "src/lib/parser/cmdline_parser/cmdline_parser.h"
     
    4342  ID_SET_INI = 1,
    4443  ID_HELP,
    45   ID_LICENSE,
    46   ID_LAST
     44  ID_PREFS
    4745};
    4846
  • branches/preferences/src/orxonox.cc

    r7251 r7254  
    6868SHELL_COMMAND(restart, Orxonox, restart);
    6969
    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" );
     70REGISTER_ARG_FLAG( l, license, "misc", "showLicenseAndExit", "Prints the licence and exit",    "1" );
     71REGISTER_ARG_FLAG( c, client,  "game", "gameType",           "Connect to Server (-H)",         "multiplayer_client" );
     72REGISTER_ARG_FLAG( s, server,  "game", "gameType",           "Start Orxonox as Game Server",   "multiplayer_server" );
     73REGISTER_ARG_ARG(  H, host,    "game", "host",               "Host to connect to",             "host");
     74REGISTER_ARG_ARG(  p, port,    "game", "port",               "Port to use",                    "port" );
     75REGISTER_ARG_FLAG( g, gui,     "game", "showGui",            "starts the orxonox with the configuration GUI", "1");
    7276
    7377/**
     
    408412  prefs.parse(argc, argv);
    409413 
    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 
    425426  return startOrxonox(argc, argv, NULL, -1);
    426427  return 0;
    427428}
    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 
    456429
    457430
     
    465438{
    466439
    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 == "" )
    471448    {
    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;
    485451    }
    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);
    500464  }
    501465}
  • branches/preferences/src/orxonox.h

    r7250 r7254  
    5757// Start-up functions //
    5858////////////////////////
    59 int showHelp(int argc, char** argv);
    60 int showLicense();
     59
    6160int startNetworkOrxonox(int argc, char** argv);
    6261int startOrxonox(int argc, char** argv, const char* clientName, int port);
Note: See TracChangeset for help on using the changeset viewer.