Changeset 4122 in orxonox.OLD for orxonox/branches/heightMap/src/orxonox.cc
- Timestamp:
- May 9, 2005, 11:29:19 AM (20 years ago)
- Location:
- orxonox/branches/heightMap
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
orxonox/branches/heightMap
- Property svn:externals
-
old new 1 data http://svn.orxonox.ethz.ch/data 1
-
- Property svn:externals
-
orxonox/branches/heightMap/src/orxonox.cc
r3790 r4122 22 22 main-programmer: Patrick Boenzli 23 23 co-programmer: Christian Meyer 24 co-programmer: Benjamin Grauer: injected ResourceManager/GraphicsEngine 24 co-programmer: Benjamin Grauer: injected ResourceManager/GraphicsEngine/GUI 25 25 */ 26 26 27 27 #include "orxonox.h" 28 29 #include "gui.h" 28 30 29 31 #include "world.h" 30 32 #include "data_tank.h" 31 33 #include "command_node.h" 34 #include "ini_parser.h" 32 35 #include "game_loader.h" 33 36 #include "graphics_engine.h" 34 37 #include "resource_manager.h" 35 38 #include "text_engine.h" 39 #include "factory.h" 36 40 37 41 #include <string.h> 38 int verbose = 3; 42 43 int verbose = 4; 39 44 40 45 using namespace std; … … 45 50 Orxonox::Orxonox () 46 51 { 47 pause = false; 52 this->pause = false; 53 54 this->world = NULL; 55 this->resources = NULL; 56 this->localinput = NULL; 48 57 } 49 58 … … 53 62 Orxonox::~Orxonox () 54 63 { 64 int i =0; 55 65 Orxonox::singletonRef = NULL; 56 66 if( world != NULL) delete world; 57 if( localinput != NULL) delete world;67 if( localinput != NULL) delete localinput; 58 68 if( resources != NULL) delete resources; 59 69 delete GraphicsEngine::getInstance(); // deleting the Graphics … … 84 94 void Orxonox::getConfigFile (int argc, char** argv) 85 95 { 86 strcpy (configfilename, " orxonox.conf");96 strcpy (configfilename, "~/.orxonox/orxonox.conf"); 87 97 } 88 98 … … 98 108 SDL_Init (SDL_INIT_TIMER); 99 109 // initialize everything 110 printf("> Initializing resources\n"); 111 if( initResources () == -1) return -1; 112 100 113 if( initVideo() == -1) return -1; 101 114 if( initSound() == -1) return -1; … … 104 117 printf("> Initializing networking\n"); 105 118 if( initNetworking () == -1) return -1; 106 printf("> Initializing resources\n");107 if( initResources () == -1) return -1;108 119 //printf("> Initializing world\n"); 109 120 //if( init_world () == -1) return -1; PB: world will be initialized when started … … 143 154 { 144 155 // create localinput 145 localinput = new CommandNode( 156 localinput = new CommandNode(configfilename); 146 157 147 158 return 0; … … 164 175 int Orxonox::initResources() 165 176 { 166 // printf("Not yet implemented\n");167 177 PRINT(3)("initializing ResourceManager\n"); 168 178 resourceManager = ResourceManager::getInstance(); 169 resourceManager->setDataDir("../data/"); 170 return 0; 179 180 // create parser 181 IniParser parser (DEFAULT_CONFIG_FILE); 182 if( parser.getSection (CONFIG_SECTION_DATA) == -1) 183 { 184 PRINTF(1)("Could not find Section %s in %s\n", CONFIG_SECTION_DATA, DEFAULT_CONFIG_FILE); 185 return -1; 186 } 187 char namebuf[256]; 188 char valuebuf[256]; 189 memset (namebuf, 0, 256); 190 memset (valuebuf, 0, 256); 191 192 while( parser.nextVar (namebuf, valuebuf) != -1) 193 { 194 if (!strcmp(namebuf, CONFIG_NAME_DATADIR)) 195 { 196 // printf("Not yet implemented\n"); 197 if (!resourceManager->setDataDir(valuebuf)) 198 { 199 PRINTF(1)("Data Could not be located\n"); 200 exit(-1); 201 } 202 } 203 204 memset (namebuf, 0, 256); 205 memset (valuebuf, 0, 256); 206 } 207 208 if (!resourceManager->checkDataDir(DEFAULT_DATA_DIR_CHECKFILE)) 209 { 210 PRINTF(1)("The DataDirectory %s could not be verified\nPlease Change in File %s Section %s Entry %s to a suitable value\n", 211 resourceManager->getDataDir(), 212 DEFAULT_CONFIG_FILE, 213 CONFIG_SECTION_DATA, 214 CONFIG_NAME_DATADIR); 215 exit(-1); 216 } 217 218 171 219 PRINT(3)("initializing TextEngine\n"); 172 220 TextEngine::getInstance(); … … 200 248 201 249 this->gameLoader = GameLoader::getInstance(); 202 this->gameLoader->loadDebugCampaign(DEBUG_CAMPAIGN_0); 250 this->gameLoader->loadCampaign("worlds/DefaultCampaign.oxc"); 251 // this->gameLoader->loadDebugCampaign(DEBUG_CAMPAIGN_0); 203 252 this->gameLoader->init(); 204 253 this->gameLoader->start(); … … 279 328 280 329 330 bool showGui = false; 281 331 282 332 /** … … 300 350 301 351 int i; 302 for(i = 0; i < argc; ++i)352 for(i = 1; i < argc; ++i) 303 353 { 304 354 if(! strcmp( "--help", argv[i])) return startHelp(); 305 355 else if(! strcmp( "--benchmark", argv[i])) return startBenchmarks(); 306 } 307 308 PRINTF(2)("Orxonox does not understand the arguments"); 356 else if(! strcmp( "--gui", argv[i]) || !strcmp("-g", argv[i])) showGui = true; 357 else PRINTF(2)("Orxonox does not understand the arguments %s\n", argv[i]); 358 } 359 309 360 return startOrxonox(argc, argv); 310 361 } … … 314 365 int startHelp() 315 366 { 316 printf("orxonox: starts the orxonox game - rules\n"); 317 printf("usage: orxonox [arg]\n\n"); 318 printf("valid options:\n"); 319 printf(" --benchmark\tstarts the orxonox benchmark\n"); 320 printf(" --help \tshows this menu\n"); 367 PRINT(0)("orxonox: starts the orxonox game - rules\n"); 368 PRINT(0)("usage: orxonox [arg]\n\n"); 369 PRINT(0)("valid options:\n"); 370 PRINT(0)(" --benchmark\tstarts the orxonox benchmark\n"); 371 PRINT(0)(" --help \tshows this menu\n"); 372 PRINT(0)(" --gui/-g \tDisplays the Gui on startup\n"); 321 373 } 322 374 … … 324 376 int startOrxonox(int argc, char** argv) 325 377 { 326 printf(">>> Starting Orxonox <<<\n"); 378 // checking for existence of the configuration-files 379 if (showGui || 380 !ResourceManager::isFile("~/.orxonox/orxonox.conf") || 381 ResourceManager::isFile("~/.orxonox/orxonox.lock")) 382 { 383 if (ResourceManager::isFile("~/.orxonox/orxonox.lock")) 384 ResourceManager::deleteFile("~/.orxonox/orxonox.lock"); 385 // char* guiExec = new char[strlen(argv[0])+20]; 386 // sprintf(guiExec,"%sGui --gui", argv[0]); 387 Gui* gui = new Gui(argc, argv); 388 if (! gui->startOrxonox) 389 return 0; 390 391 delete gui; 392 } 393 394 PRINT(0)(">>> Starting Orxonox <<<\n"); 395 396 ResourceManager::touchFile("~/.orxonox/orxonox.lock"); 397 327 398 Orxonox *orx = Orxonox::getInstance(); 328 399 329 400 if((*orx).init(argc, argv) == -1) 330 401 { 331 printf("! Orxonox initialization failed\n");402 PRINTF(1)("! Orxonox initialization failed\n"); 332 403 return -1; 333 404 } … … 336 407 337 408 delete orx; 409 ResourceManager::deleteFile("~/.orxonox/orxonox.lock"); 338 410 339 411 } … … 346 418 #include "player.h" 347 419 #include "base_object.h" 420 348 421 #include <asm/msr.h> 349 422 #include <linux/timex.h>
Note: See TracChangeset
for help on using the changeset viewer.