Index: /branches/preferences/src/lib/parser/preferences/cmd_line_prefs_reader.cc
===================================================================
--- /branches/preferences/src/lib/parser/preferences/cmd_line_prefs_reader.cc	(revision 7250)
+++ /branches/preferences/src/lib/parser/preferences/cmd_line_prefs_reader.cc	(revision 7251)
@@ -21,4 +21,6 @@
 
 using namespace std;
+
+RegistredArgs CmdLinePrefsReader::regArgs;
 
 /**
@@ -64,11 +66,33 @@
       cbd->iniEntries.back().key = key;
       cbd->iniEntries.back().value = argArgs[0].getString();
-      break;
+      return true;
     }
     case ID_HELP:
       cbd->parser->showHelp();
-      break;
-    default:
-      assert(false);
+      return true;
+  }
+  
+  if ( entry.id >= ID_LAST && entry.id - ID_LAST < regArgs.size() )
+  {
+    if ( regArgs[entry.id - ID_LAST].value == "%arg%" )
+    {
+      assert( argArgs.size() == 1 );
+      
+      cbd->iniEntries.push_back( IniEntry() );
+      cbd->iniEntries.back().section = regArgs[entry.id - ID_LAST].section;
+      cbd->iniEntries.back().key = regArgs[entry.id - ID_LAST].key;
+      cbd->iniEntries.back().value = argArgs[0].getString();
+    }
+    else
+    {
+      cbd->iniEntries.push_back( IniEntry() );
+      cbd->iniEntries.back().section = regArgs[entry.id - ID_LAST].section;
+      cbd->iniEntries.back().key = regArgs[entry.id - ID_LAST].key;
+      cbd->iniEntries.back().value = regArgs[entry.id - ID_LAST].value;
+    }
+  }
+  else
+  {
+    assert(false);
   }
   
@@ -81,6 +105,17 @@
   CmdLineParser parser;
   
-  parser.add( ID_HELP, "help", 'h', 0, "", "Show this help");
-  parser.add( 99, "port", 'p', 0, "", "dont know");
+  parser.add( ID_HELP, "help", 'h', 0, "", "Shows this help");
+  
+  for ( int i = 0; i<regArgs.size(); i++ )
+  {
+    if ( regArgs[i].value == "%arg%" )
+    {
+      parser.add( ID_LAST + i, regArgs[i].longOption, regArgs[i].shortOption, 1, regArgs[i].argName, regArgs[i].help );
+    }
+    else
+    {
+      parser.add( ID_LAST + i, regArgs[i].longOption, regArgs[i].shortOption, 0, "", regArgs[i].help );
+    }
+  }
   
   parser.add( ID_SET_INI, "set-%", '\0', 1, "value", "Override a configuration element." );
@@ -90,5 +125,33 @@
   cbd.parser = &parser;
   
-  parser.parse( &callBack, &cbd, argc, argv );
+  if ( parser.parse( &callBack, &cbd, argc, argv ) )
+  {
+    std::list<IniEntry>::const_iterator it;
+    for ( it = cbd.iniEntries.begin(); it != cbd.iniEntries.end(); it++ )
+    {
+      Preferences::getInstance()->setString( it->section, it->key, it->value, true);
+    }
+  }
+  else
+  {
+    exit(EXIT_FAILURE);
+  }
+  
+  return true;
+}
+
+bool CmdLinePrefsReader::registerArgument( const char shortOption, const std::string & longOption, const std::string & section, const std::string & key, const std::string & help, const std::string & argName, const std::string & value )
+{
+  RegistredArgument arg;
+  
+  arg.longOption = longOption;
+  arg.shortOption = shortOption;
+  arg.value = value;
+  arg.help = help;
+  arg.argName = argName;
+  arg.section = section;
+  arg.key = key;
+  
+  regArgs.push_back( arg );
 }
 
Index: /branches/preferences/src/lib/parser/preferences/cmd_line_prefs_reader.h
===================================================================
--- /branches/preferences/src/lib/parser/preferences/cmd_line_prefs_reader.h	(revision 7250)
+++ /branches/preferences/src/lib/parser/preferences/cmd_line_prefs_reader.h	(revision 7251)
@@ -25,9 +25,27 @@
 };
 
+struct RegistredArgument
+{
+  char shortOption;
+  std::string longOption;
+  std::string value;
+  std::string help;
+  std::string argName;
+  std::string section;
+  std::string key;
+};
+
+typedef std::vector<RegistredArgument> RegistredArgs;
+
 enum
 {
   ID_SET_INI = 1,
-  ID_HELP
+  ID_HELP,
+  ID_LAST
 };
+
+#define REGISTER_ARG_FLAG(shortOption,longOption,section,key,description,value) bool _ARGVAR_##shortOption##_##longOption = CmdLinePrefsReader::registerArgument(#shortOption[0],#longOption,section,key,description,"",value) 
+
+#define REGISTER_ARG_ARG(shortOption,longOption,section,key,description,argname) bool _ARGVAR_##shortOption##_##longOption = CmdLinePrefsReader::registerArgument(#shortOption[0],#longOption,section,key,description,argname) 
 
 //! A class for reading commandline arguments into Preferences
@@ -41,6 +59,12 @@
     bool parse(int argc, char** argv);
     
+    static bool registerArgument( const char shortOption, const std::string & longOption, const std::string & section, const std::string & key, const std::string & help,  const std::string & argName = "", const std::string & value = "%arg%" );
+    
+    static bool asdf;
+    
   private:
     static bool callBack( ArgTableEntry entry, void* data, const std::string & arg, const std::vector<MultiType> & argArgs );
+    
+    static RegistredArgs regArgs;
 
 };
Index: /branches/preferences/src/orxonox.cc
===================================================================
--- /branches/preferences/src/orxonox.cc	(revision 7250)
+++ /branches/preferences/src/orxonox.cc	(revision 7251)
@@ -67,4 +67,7 @@
 
 SHELL_COMMAND(restart, Orxonox, restart);
+
+REGISTER_ARG_FLAG( s, server, "game", "isServer", "Start Orxonox as Game Server", "1" );
+REGISTER_ARG_ARG( p, port, "game", "port", "Port to use", "port" );
 
 /**
@@ -405,6 +408,4 @@
   prefs.parse(argc, argv);
   
-  //Preferences::getInstance()->debug();
-  
   int i;
   for(i = 1; i < argc; ++i)
