Changeset 2101 for code/branches/objecthierarchy/src/core/RootGameState.cc
- Timestamp:
- Nov 2, 2008, 12:09:55 AM (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/objecthierarchy/src/core/RootGameState.cc
r2003 r2101 29 29 #include "RootGameState.h" 30 30 31 #include "util/String.h"32 #include "util/SubString.h"33 31 #include "util/Debug.h" 34 32 #include "util/Exception.h" … … 130 128 State to start with (usually main menu or specified by command line) 131 129 */ 132 void RootGameState::start( int argc, char** argv)130 void RootGameState::start() 133 131 { 134 132 #ifdef NDEBUG … … 141 139 // create the Core settings to configure the output level 142 140 Core::getInstance(); 143 144 parseArguments(argc, argv);145 141 146 142 this->activate(); … … 168 164 COUT(1) << ex.what() << std::endl; 169 165 COUT(1) << "Program aborted." << std::endl; 170 abort();171 166 } 172 167 // anything that doesn't inherit from std::exception … … 174 169 { 175 170 COUT(1) << "An unidentifiable exception has occured. Program aborted." << std::endl; 176 abort();177 171 } 178 172 #endif 179 173 } 180 181 /**182 @brief183 Parses both command line and start.ini for CommandLineArguments.184 */185 void RootGameState::parseArguments(int argc, char** argv)186 {187 // parse command line first188 std::vector<std::string> args;189 for (int i = 1; i < argc; ++i)190 args.push_back(argv[i]);191 192 try193 {194 orxonox::CommandLine::parse(args);195 }196 catch (orxonox::ArgumentException& ex)197 {198 COUT(1) << ex.what() << std::endl;199 COUT(0) << "Usage:" << std::endl << "orxonox " << CommandLine::getUsageInformation() << std::endl;200 }201 202 // look for additional arguments in start.ini203 std::ifstream file;204 file.open("start.ini");205 args.clear();206 if (file)207 {208 while (!file.eof())209 {210 std::string line;211 std::getline(file, line);212 line = removeTrailingWhitespaces(line);213 //if (!(line[0] == '#' || line[0] == '%'))214 //{215 SubString tokens(line, " ", " ", false, 92, false, 34, false, 40, 41, false, '#');216 for (unsigned i = 0; i < tokens.size(); ++i)217 if (tokens[i][0] != '#')218 args.push_back(tokens[i]);219 //args.insert(args.end(), tokens.getAllStrings().begin(), tokens.getAllStrings().end());220 //}221 }222 file.close();223 }224 225 try226 {227 orxonox::CommandLine::parse(args);228 }229 catch (orxonox::ArgumentException& ex)230 {231 COUT(1) << "An Exception occured while parsing start.ini" << std::endl;232 COUT(1) << ex.what() << std::endl;233 COUT(0) << "Usage:" << std::endl << "orxonox " << CommandLine::getUsageInformation() << std::endl;234 }235 }236 174 }
Note: See TracChangeset
for help on using the changeset viewer.