[4982] | 1 | /* |
---|
[1850] | 2 | orxonox - the future of 3D-vertical-scrollers |
---|
| 3 | |
---|
| 4 | Copyright (C) 2004 orx |
---|
| 5 | |
---|
| 6 | This program is free software; you can redistribute it and/or modify |
---|
| 7 | it under the terms of the GNU General Public License as published by |
---|
| 8 | the Free Software Foundation; either version 2, or (at your option) |
---|
| 9 | any later version. |
---|
| 10 | |
---|
| 11 | This program is distributed in the hope that it will be useful, |
---|
| 12 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
---|
| 13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
---|
| 14 | GNU General Public License for more details. |
---|
| 15 | |
---|
| 16 | You should have received a copy of the GNU General Public License |
---|
| 17 | along with this program; if not, write to the Free Software Foundation, |
---|
[4556] | 18 | Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
---|
[1850] | 19 | |
---|
[1855] | 20 | |
---|
| 21 | ### File Specific: |
---|
| 22 | main-programmer: Patrick Boenzli |
---|
[5303] | 23 | co-programmer: Christian Meyer |
---|
[4054] | 24 | co-programmer: Benjamin Grauer: injected ResourceManager/GraphicsEngine/GUI |
---|
[1850] | 25 | */ |
---|
| 26 | |
---|
[5303] | 27 | #define DEBUG_SPECIAL_MODULE DEBUG_MODULE_ORXONOX |
---|
[2190] | 28 | #include "orxonox.h" |
---|
[3610] | 29 | |
---|
[5819] | 30 | #include "globals.h" |
---|
[6351] | 31 | #include "class_list.h" |
---|
[5819] | 32 | |
---|
[4054] | 33 | #include "gui.h" |
---|
| 34 | |
---|
[5944] | 35 | #include "parser/ini_parser/ini_parser.h" |
---|
[4786] | 36 | |
---|
[6351] | 37 | |
---|
| 38 | // load the core engines |
---|
[3610] | 39 | #include "graphics_engine.h" |
---|
[4504] | 40 | #include "sound_engine.h" |
---|
[3655] | 41 | #include "resource_manager.h" |
---|
[4786] | 42 | #include "cd_engine.h" |
---|
| 43 | #include "event_handler.h" |
---|
[6351] | 44 | #include "network_manager.h" |
---|
| 45 | #include "game_loader.h" |
---|
[4786] | 46 | |
---|
[6351] | 47 | |
---|
[4010] | 48 | #include "factory.h" |
---|
[4980] | 49 | #include "fast_factory.h" |
---|
| 50 | |
---|
[6351] | 51 | // #include "benchmark.h" |
---|
[3610] | 52 | |
---|
[6351] | 53 | |
---|
[5641] | 54 | #include "shell_command_class.h" |
---|
[5165] | 55 | #include "shell_command.h" |
---|
[5175] | 56 | #include "shell_buffer.h" |
---|
[5546] | 57 | #include "load_param_description.h" |
---|
[5226] | 58 | |
---|
[5996] | 59 | |
---|
[2190] | 60 | #include <string.h> |
---|
[4032] | 61 | |
---|
[4885] | 62 | int verbose = 4; |
---|
[2036] | 63 | |
---|
[1803] | 64 | using namespace std; |
---|
| 65 | |
---|
[5207] | 66 | |
---|
[6351] | 67 | |
---|
[2190] | 68 | /** |
---|
[4836] | 69 | * create a new Orxonox |
---|
[4135] | 70 | |
---|
| 71 | In this funcitons only global values are set. The game will not be started here. |
---|
[2190] | 72 | */ |
---|
| 73 | Orxonox::Orxonox () |
---|
[1872] | 74 | { |
---|
[4445] | 75 | this->setClassID(CL_ORXONOX, "Orxonox"); |
---|
[4766] | 76 | this->setName("orxonox-main"); |
---|
[4059] | 77 | |
---|
[4766] | 78 | this->iniParser = NULL; |
---|
[4135] | 79 | |
---|
| 80 | this->argc = 0; |
---|
| 81 | this->argv = NULL; |
---|
[4782] | 82 | |
---|
[5996] | 83 | /* this way, there is no network enabled: */ |
---|
| 84 | this->serverName = NULL; |
---|
| 85 | this->port = -1; |
---|
| 86 | |
---|
[4830] | 87 | this->configFileName = NULL; |
---|
[1872] | 88 | } |
---|
[1803] | 89 | |
---|
[2190] | 90 | /** |
---|
[4836] | 91 | * remove Orxonox from memory |
---|
[2190] | 92 | */ |
---|
[4556] | 93 | Orxonox::~Orxonox () |
---|
[2190] | 94 | { |
---|
[5285] | 95 | // game-specific |
---|
[4815] | 96 | delete GameLoader::getInstance(); |
---|
[5285] | 97 | |
---|
| 98 | // class-less services/factories |
---|
[5982] | 99 | Factory::deleteFactories(); |
---|
[4980] | 100 | FastFactory::deleteAll(); |
---|
[5171] | 101 | ShellCommandClass::unregisterAllCommands(); |
---|
[5332] | 102 | |
---|
[5226] | 103 | LoadClassDescription::deleteAllDescriptions(); |
---|
| 104 | |
---|
[5285] | 105 | // engines |
---|
| 106 | delete CDEngine::getInstance(); |
---|
| 107 | delete SoundEngine::getInstance(); |
---|
| 108 | delete GraphicsEngine::getInstance(); // deleting the Graphics |
---|
[4817] | 109 | delete EventHandler::getInstance(); |
---|
[5285] | 110 | |
---|
| 111 | // handlers |
---|
| 112 | delete ResourceManager::getInstance(); // deletes the Resource Manager |
---|
| 113 | // output-buffer |
---|
| 114 | delete ShellBuffer::getInstance(); |
---|
| 115 | |
---|
| 116 | // orxonox class-stuff |
---|
[5078] | 117 | delete this->iniParser; |
---|
[5210] | 118 | delete[] this->configFileName; |
---|
[4817] | 119 | |
---|
[5225] | 120 | SDL_QuitSubSystem(SDL_INIT_TIMER); |
---|
[4942] | 121 | ClassList::debug(); |
---|
[1850] | 122 | |
---|
[4833] | 123 | PRINT(3) |
---|
[5996] | 124 | ( |
---|
| 125 | "===================================================\n" \ |
---|
| 126 | "Thanks for playing orxonox.\n" \ |
---|
| 127 | "visit: http://www.orxonox.net for new versions.\n" \ |
---|
| 128 | "===================================================\n" \ |
---|
| 129 | ORXONOX_LICENSE_SHORT |
---|
| 130 | ); |
---|
[1872] | 131 | |
---|
[4766] | 132 | Orxonox::singletonRef = NULL; |
---|
[1850] | 133 | } |
---|
| 134 | |
---|
[2190] | 135 | /** |
---|
[4836] | 136 | * this is a singleton class to prevent duplicates |
---|
[4766] | 137 | */ |
---|
| 138 | Orxonox* Orxonox::singletonRef = NULL; |
---|
[4556] | 139 | |
---|
[5207] | 140 | |
---|
[4766] | 141 | /** |
---|
[4836] | 142 | * this finds the config file |
---|
[4766] | 143 | * @returns the new config-fileName |
---|
| 144 | * Since the config file varies from user to user and since one may want to specify different config files |
---|
| 145 | * for certain occasions or platforms this function finds the right config file for every occasion and stores |
---|
| 146 | * it's path and name into configfilename |
---|
[2190] | 147 | */ |
---|
[4830] | 148 | const char* Orxonox::getConfigFile () |
---|
[1850] | 149 | { |
---|
[5424] | 150 | if (ResourceManager::isFile("orxonox.conf")) |
---|
| 151 | { |
---|
| 152 | this->configFileName = new char[strlen("orxonox.conf")+1]; |
---|
| 153 | strcpy(this->configFileName, "orxonox.conf"); |
---|
| 154 | } |
---|
| 155 | else |
---|
| 156 | this->configFileName = ResourceManager::homeDirCheck(DEFAULT_CONFIG_FILE); |
---|
[4766] | 157 | this->iniParser = new IniParser(this->configFileName); |
---|
[5424] | 158 | PRINTF(3)("Parsed Config File: '%s'\n", this->configFileName); |
---|
[1803] | 159 | } |
---|
| 160 | |
---|
[2190] | 161 | /** |
---|
[4833] | 162 | * initialize Orxonox with command line |
---|
| 163 | */ |
---|
[5996] | 164 | int Orxonox::init (int argc, char** argv, const char* name, int port) |
---|
[1803] | 165 | { |
---|
[4135] | 166 | this->argc = argc; |
---|
| 167 | this->argv = argv; |
---|
[4556] | 168 | |
---|
[6351] | 169 | |
---|
[5996] | 170 | this->serverName = name; |
---|
| 171 | this->port = port; |
---|
| 172 | |
---|
[4766] | 173 | // initialize the Config-file |
---|
[4830] | 174 | this->getConfigFile(); |
---|
[4766] | 175 | |
---|
[5788] | 176 | // windows must not write into stdout.txt and stderr.txt |
---|
| 177 | #ifdef __WIN32__ |
---|
| 178 | freopen( "CON", "w", stdout ); |
---|
| 179 | freopen( "CON", "w", stderr ); |
---|
| 180 | #endif |
---|
| 181 | |
---|
[5996] | 182 | // initialize everything |
---|
[6079] | 183 | SDL_Init(0); |
---|
[6351] | 184 | if( initResources (argc, argv) == -1) |
---|
[5996] | 185 | return -1; |
---|
[6351] | 186 | if( initVideo(argc, argv) == -1) |
---|
[5996] | 187 | return -1; |
---|
[6351] | 188 | if( initSound(argc, argv) == -1) |
---|
[5996] | 189 | return -1; |
---|
[6351] | 190 | if( initInput(argc, argv) == -1) |
---|
[5996] | 191 | return -1; |
---|
[6351] | 192 | if( initNetworking (argc, argv) == -1) |
---|
[5996] | 193 | return -1; |
---|
[6351] | 194 | if( initMisc (argc, argv) == -1) |
---|
[5996] | 195 | return -1; |
---|
[4556] | 196 | |
---|
[2636] | 197 | return 0; |
---|
[1850] | 198 | } |
---|
[1849] | 199 | |
---|
[5996] | 200 | |
---|
[2190] | 201 | /** |
---|
[4833] | 202 | * initializes SDL and OpenGL |
---|
[5996] | 203 | */ |
---|
[6351] | 204 | int Orxonox::initVideo(int argc, char** argv) |
---|
[2190] | 205 | { |
---|
[3611] | 206 | PRINTF(3)("> Initializing video\n"); |
---|
[4556] | 207 | |
---|
[6351] | 208 | for( int i = 0; i < argc; i++) |
---|
| 209 | if( !strcmp( "--dedicated-server", argv[i]) || !strcmp("-ds", argv[i])) |
---|
| 210 | this->dedicatedServer = 1; |
---|
| 211 | |
---|
| 212 | |
---|
[3610] | 213 | GraphicsEngine::getInstance(); |
---|
[4556] | 214 | |
---|
[4784] | 215 | GraphicsEngine::getInstance()->initFromIniFile(this->iniParser); |
---|
[4766] | 216 | |
---|
[5219] | 217 | char* iconName = ResourceManager::getFullName("pictures/fighter-top-32x32.bmp"); |
---|
[5225] | 218 | if (iconName != NULL) |
---|
| 219 | { |
---|
| 220 | GraphicsEngine::getInstance()->setWindowName(PACKAGE_NAME " " PACKAGE_VERSION, iconName); |
---|
| 221 | delete[] iconName; |
---|
| 222 | } |
---|
[6351] | 223 | |
---|
| 224 | /* if this orxonox program is a dedicated server - don't draw anything */ |
---|
| 225 | if( this->dedicatedServer == 1) |
---|
| 226 | { |
---|
| 227 | |
---|
| 228 | } |
---|
[2190] | 229 | return 0; |
---|
| 230 | } |
---|
[1850] | 231 | |
---|
[5996] | 232 | |
---|
[2190] | 233 | /** |
---|
[4833] | 234 | * initializes the sound engine |
---|
| 235 | */ |
---|
[6351] | 236 | int Orxonox::initSound(int argc, char** argv) |
---|
[2190] | 237 | { |
---|
[4504] | 238 | PRINT(3)("> Initializing sound\n"); |
---|
[5225] | 239 | // SDL_InitSubSystem(SDL_INIT_AUDIO); |
---|
[4504] | 240 | SoundEngine::getInstance()->initAudio(); |
---|
[5930] | 241 | SoundEngine::getInstance()->allocateSources(1); |
---|
[4985] | 242 | |
---|
| 243 | SoundEngine::getInstance()->loadSettings(this->iniParser); |
---|
[2636] | 244 | return 0; |
---|
[2190] | 245 | } |
---|
[1900] | 246 | |
---|
[3214] | 247 | |
---|
[2190] | 248 | /** |
---|
[4833] | 249 | * initializes input functions |
---|
| 250 | */ |
---|
[6351] | 251 | int Orxonox::initInput(int argc, char** argv) |
---|
[2190] | 252 | { |
---|
[4766] | 253 | PRINT(3)("> Initializing input\n"); |
---|
| 254 | |
---|
[4866] | 255 | EventHandler::getInstance()->init(this->iniParser); |
---|
[4833] | 256 | EventHandler::getInstance()->subscribe(GraphicsEngine::getInstance(), ES_ALL, EV_VIDEO_RESIZE); |
---|
[4556] | 257 | |
---|
[2636] | 258 | return 0; |
---|
[1803] | 259 | } |
---|
| 260 | |
---|
[3214] | 261 | |
---|
[2190] | 262 | /** |
---|
[4833] | 263 | * initializes network system |
---|
| 264 | */ |
---|
[6351] | 265 | int Orxonox::initNetworking(int argc, char** argv) |
---|
[1897] | 266 | { |
---|
[4766] | 267 | PRINT(3)("> Initializing networking\n"); |
---|
| 268 | |
---|
[6351] | 269 | /* command line parsing |
---|
| 270 | parsing following commands: |
---|
| 271 | --client or -c |
---|
| 272 | --server or -s |
---|
| 273 | --dedicated-server or -ds |
---|
| 274 | */ |
---|
| 275 | int i; |
---|
| 276 | for( i = 0; i < argc; ++i ) |
---|
| 277 | { |
---|
| 278 | if( !strcmp( "--client", argv[i]) || !strcmp("-c", argv[i])) |
---|
| 279 | { |
---|
| 280 | if( argc <= (i+2)) |
---|
| 281 | { |
---|
| 282 | printf(" Wrong arguments try following notations:\n"); |
---|
| 283 | printf(" --client [server ip address] [port number]\n"); |
---|
| 284 | printf(" --client [dns name] [port number]\n"); |
---|
| 285 | return -1; |
---|
| 286 | } |
---|
| 287 | |
---|
| 288 | const char* name = argv[i+1]; |
---|
| 289 | int port = atoi(argv[i+2]); |
---|
| 290 | printf("Starting Orxonox as client: connecting to %s, on port %i\n", name, port); |
---|
| 291 | |
---|
| 292 | this->serverName = name; |
---|
| 293 | this->port = port; |
---|
| 294 | } |
---|
| 295 | else if( !strcmp( "--server", argv[i]) || !strcmp("-s", argv[i])) |
---|
| 296 | { |
---|
| 297 | if( argc <= (i+1)) |
---|
| 298 | { |
---|
| 299 | printf(" Wrong arguments try following notations:\n"); |
---|
| 300 | printf(" --server [port number]\n"); |
---|
| 301 | return -1; |
---|
| 302 | } |
---|
| 303 | |
---|
| 304 | int port = atoi(argv[i+1]); |
---|
| 305 | printf("Starting Orxonox as server, listening on port %i\n", port); |
---|
| 306 | |
---|
| 307 | this->serverName = NULL; |
---|
| 308 | this->port = port; |
---|
| 309 | } |
---|
| 310 | else if( !strcmp( "--dedicated-server", argv[i]) || !strcmp("-ds", argv[i])) |
---|
| 311 | { |
---|
| 312 | if( argc <= (i+1)) |
---|
| 313 | { |
---|
| 314 | printf(" Wrong arguments try following notations:\n"); |
---|
| 315 | printf(" --dedicated-server [port number]\n"); |
---|
| 316 | return -1; |
---|
| 317 | } |
---|
| 318 | |
---|
| 319 | int port = atoi(argv[i+1]); |
---|
| 320 | printf("Starting Orxonox as dedicated-server, listening on port %i\n", port); |
---|
| 321 | |
---|
| 322 | this->serverName = NULL; |
---|
| 323 | this->port = port; |
---|
| 324 | /*this->dedicatedServer = 1; - this is already been done in the initVideo(...) function*/ |
---|
| 325 | } |
---|
| 326 | } |
---|
| 327 | |
---|
| 328 | |
---|
[5996] | 329 | if( this->serverName != NULL) // we are a client |
---|
| 330 | NetworkManager::getInstance()->establishConnection(this->serverName, port); |
---|
[6139] | 331 | else if( this->port > 0) { // we are a server |
---|
[5996] | 332 | NetworkManager::getInstance()->createServer(port); |
---|
[6139] | 333 | } |
---|
[5996] | 334 | |
---|
[2636] | 335 | return 0; |
---|
[1897] | 336 | } |
---|
| 337 | |
---|
[3214] | 338 | |
---|
[2190] | 339 | /** |
---|
[4833] | 340 | * initializes and loads resource files |
---|
[4766] | 341 | */ |
---|
[6351] | 342 | int Orxonox::initResources(int argc, char** argv) |
---|
[1858] | 343 | { |
---|
[4766] | 344 | PRINTF(3)("> Initializing resources\n"); |
---|
[4091] | 345 | |
---|
[4766] | 346 | PRINT(3)("initializing ResourceManager\n"); |
---|
| 347 | |
---|
[5488] | 348 | // init the resource manager |
---|
[5014] | 349 | const char* dataPath; |
---|
| 350 | if ((dataPath = this->iniParser->getVar(CONFIG_NAME_DATADIR, CONFIG_SECTION_DATA))!= NULL) |
---|
[4766] | 351 | { |
---|
[5480] | 352 | if (!ResourceManager::getInstance()->setDataDir(dataPath) && |
---|
[5996] | 353 | !ResourceManager::getInstance()->verifyDataDir(DEFAULT_DATA_DIR_CHECKFILE)) |
---|
[4766] | 354 | { |
---|
[5423] | 355 | PRINTF(1)("Data Could not be located in %s\n", dataPath); |
---|
[4766] | 356 | } |
---|
| 357 | } |
---|
[4556] | 358 | |
---|
[5480] | 359 | if (!ResourceManager::getInstance()->verifyDataDir(DEFAULT_DATA_DIR_CHECKFILE)) |
---|
[4766] | 360 | { |
---|
[5510] | 361 | PRINTF(1)("The DataDirectory %s could not be verified\n\nh" \ |
---|
| 362 | "!!! Please Change in File %s Section %s Entry %s to a suitable value !!!\n", |
---|
[4822] | 363 | ResourceManager::getInstance()->getDataDir(), |
---|
[5424] | 364 | this->configFileName, |
---|
[4766] | 365 | CONFIG_SECTION_DATA, |
---|
[5510] | 366 | CONFIG_NAME_DATADIR ); |
---|
[5479] | 367 | Gui* gui = new Gui(argc, argv); |
---|
| 368 | gui->startGui(); |
---|
| 369 | delete gui; |
---|
[4766] | 370 | exit(-1); |
---|
| 371 | } |
---|
[5996] | 372 | //! @todo this is a hack and should be loadable |
---|
[5335] | 373 | char* imageDir = ResourceManager::getInstance()->getFullName("maps"); |
---|
[5216] | 374 | ResourceManager::getInstance()->addImageDir(imageDir); |
---|
| 375 | delete[] imageDir; |
---|
[4009] | 376 | |
---|
[5488] | 377 | // start the collision detection engine |
---|
[4766] | 378 | CDEngine::getInstance(); |
---|
[5074] | 379 | return 0; |
---|
| 380 | } |
---|
| 381 | |
---|
| 382 | /** |
---|
| 383 | * initializes miscelaneous features |
---|
| 384 | * @return -1 on failure |
---|
| 385 | */ |
---|
[6351] | 386 | int Orxonox::initMisc(int argc, char** argv) |
---|
[5074] | 387 | { |
---|
[5183] | 388 | ShellBuffer::getInstance(); |
---|
[4766] | 389 | return 0; |
---|
[1858] | 390 | } |
---|
[1849] | 391 | |
---|
[2190] | 392 | /** |
---|
[4836] | 393 | * starts the orxonox game or menu |
---|
[4833] | 394 | * here is the central orxonox state manager. There are currently two states |
---|
| 395 | * - menu |
---|
| 396 | * - game-play |
---|
| 397 | * both states manage their states themselfs again. |
---|
[2190] | 398 | */ |
---|
[2636] | 399 | void Orxonox::start() |
---|
| 400 | { |
---|
[4556] | 401 | |
---|
[2636] | 402 | this->gameLoader = GameLoader::getInstance(); |
---|
[5996] | 403 | |
---|
[6139] | 404 | if( this->port != -1) |
---|
| 405 | this->gameLoader->loadNetworkCampaign("worlds/DefaultNetworkCampaign.oxc"); |
---|
[5996] | 406 | else |
---|
[6139] | 407 | this->gameLoader->loadCampaign("worlds/DefaultCampaign.oxc"); /* start orxonox in single player mode */ |
---|
[5996] | 408 | |
---|
[4010] | 409 | // this->gameLoader->loadDebugCampaign(DEBUG_CAMPAIGN_0); |
---|
[2636] | 410 | this->gameLoader->init(); |
---|
| 411 | this->gameLoader->start(); |
---|
| 412 | } |
---|
| 413 | |
---|
[3214] | 414 | |
---|
[2636] | 415 | /** |
---|
[4833] | 416 | * handles sprecial events from localinput |
---|
| 417 | * @param event: an event not handled by the CommandNode |
---|
| 418 | */ |
---|
[4817] | 419 | // void Orxonox::graphicsHandler(SDL_Event* event) |
---|
| 420 | // { |
---|
| 421 | // // Handle special events such as reshape, quit, focus changes |
---|
| 422 | // switch (event->type) |
---|
| 423 | // { |
---|
| 424 | // case SDL_VIDEORESIZE: |
---|
| 425 | // GraphicsEngine* tmpGEngine = GraphicsEngine::getInstance(); |
---|
| 426 | // tmpGEngine->resolutionChanged(event->resize); |
---|
| 427 | // break; |
---|
| 428 | // } |
---|
| 429 | // } |
---|
[1875] | 430 | |
---|
[4556] | 431 | |
---|
[4408] | 432 | |
---|
[1803] | 433 | |
---|
[3214] | 434 | |
---|
[4782] | 435 | |
---|
[4059] | 436 | bool showGui = false; |
---|
[3648] | 437 | |
---|
[4766] | 438 | |
---|
| 439 | |
---|
| 440 | /********************************** |
---|
| 441 | *** ORXONOX MAIN STARTING POINT *** |
---|
| 442 | **********************************/ |
---|
[3449] | 443 | /** |
---|
[4833] | 444 | * |
---|
[4836] | 445 | * main function |
---|
[4833] | 446 | * |
---|
| 447 | * here the journey begins |
---|
[3449] | 448 | */ |
---|
[4556] | 449 | int main(int argc, char** argv) |
---|
| 450 | { |
---|
[3648] | 451 | int i; |
---|
[4032] | 452 | for(i = 1; i < argc; ++i) |
---|
[5996] | 453 | { |
---|
| 454 | if( !strcmp( "--help", argv[i]) || !strcmp("-h", argv[i])) |
---|
| 455 | return showHelp(argc, argv); |
---|
| 456 | else if(!strcmp( "--gui", argv[i]) || !strcmp("-g", argv[i])) |
---|
| 457 | showGui = true; |
---|
[6375] | 458 | else if(!strcmp( "--license", argv[i]) || !strcmp("-l", argv[i])) |
---|
[5996] | 459 | return PRINT(0)(ORXONOX_LICENSE_SHORT); |
---|
| 460 | } |
---|
[3648] | 461 | |
---|
[5996] | 462 | return startOrxonox(argc, argv, NULL, -1); |
---|
[3648] | 463 | } |
---|
| 464 | |
---|
| 465 | |
---|
| 466 | |
---|
[5996] | 467 | int showHelp(int argc, char** argv) |
---|
[3648] | 468 | { |
---|
[5996] | 469 | PRINT(0)("Orxonox Version %s\n", PACKAGE_VERSION); |
---|
| 470 | PRINT(0)(" Starts Orxonox - The most furious 3D Action Game :)\n"); |
---|
| 471 | PRINT(0)("\n"); |
---|
| 472 | PRINT(0)("Common options:\n"); |
---|
| 473 | PRINT(0)(" -g, --gui starts the orxonox with the configuration GUI \n"); |
---|
| 474 | PRINT(0)(" -h, --help shows this help\n"); |
---|
| 475 | PRINT(0)("\n"); |
---|
| 476 | PRINT(0)("Network options:\n"); |
---|
| 477 | PRINT(0)(" -s, --server [port] starts Orxonox and listens on the [port] for players\n"); |
---|
| 478 | PRINT(0)(" -c, --client [hostname] [port] starts Orxonox as a Client\n"); |
---|
| 479 | PRINT(0)(" -c, --client [ip address] [port] starts Orxonox as a Client\n"); |
---|
| 480 | PRINT(0)("\n"); |
---|
| 481 | PRINT(0)("Other options:\n"); |
---|
| 482 | PRINT(0)(" --license prints the licence and exit\n\n"); |
---|
| 483 | PRINT(0)("\n"); |
---|
| 484 | |
---|
| 485 | // { |
---|
| 486 | // Gui* gui = new Gui(argc, argv); |
---|
| 487 | // gui->printHelp(); |
---|
| 488 | // delete gui; |
---|
| 489 | // } |
---|
| 490 | } |
---|
| 491 | |
---|
| 492 | |
---|
| 493 | /** |
---|
[4766] | 494 | * starts orxonox |
---|
| 495 | * @param argc parameters count given to orxonox |
---|
| 496 | * @param argv parameters given to orxonox |
---|
| 497 | */ |
---|
[5996] | 498 | int startOrxonox(int argc, char** argv, const char* name, int port) |
---|
[3648] | 499 | { |
---|
[4830] | 500 | // checking for existence of the configuration-files, or if the lock file is still used |
---|
[5424] | 501 | if (showGui || (!ResourceManager::isFile("./orxonox.conf") && |
---|
[5996] | 502 | !ResourceManager::isFile(DEFAULT_CONFIG_FILE)) |
---|
[5424] | 503 | #if DEBUG < 3 // developers do not need to see the GUI, when orxonox fails |
---|
[5996] | 504 | || ResourceManager::isFile(DEFAULT_LOCK_FILE) |
---|
[4981] | 505 | #endif |
---|
| 506 | ) |
---|
[5996] | 507 | { |
---|
| 508 | if (ResourceManager::isFile(DEFAULT_LOCK_FILE)) |
---|
| 509 | ResourceManager::deleteFile(DEFAULT_LOCK_FILE); |
---|
[4556] | 510 | |
---|
[5996] | 511 | // starting the GUI |
---|
| 512 | Gui* gui = new Gui(argc, argv); |
---|
| 513 | gui->startGui(); |
---|
[4132] | 514 | |
---|
[5996] | 515 | if (! gui->startOrxonox) |
---|
| 516 | return 0; |
---|
[4556] | 517 | |
---|
[5996] | 518 | delete gui; |
---|
| 519 | } |
---|
[4556] | 520 | |
---|
[4032] | 521 | PRINT(0)(">>> Starting Orxonox <<<\n"); |
---|
[4033] | 522 | |
---|
[4766] | 523 | ResourceManager::touchFile(DEFAULT_LOCK_FILE); |
---|
[4033] | 524 | |
---|
[1850] | 525 | Orxonox *orx = Orxonox::getInstance(); |
---|
[4556] | 526 | |
---|
[5996] | 527 | if( orx->init(argc, argv, name, port) == -1) |
---|
| 528 | { |
---|
| 529 | PRINTF(1)("! Orxonox initialization failed\n"); |
---|
| 530 | return -1; |
---|
| 531 | } |
---|
[4556] | 532 | |
---|
[5996] | 533 | printf("finished inizialisation\n"); |
---|
[2636] | 534 | orx->start(); |
---|
[4556] | 535 | |
---|
[3676] | 536 | delete orx; |
---|
[4033] | 537 | ResourceManager::deleteFile("~/.orxonox/orxonox.lock"); |
---|
[1803] | 538 | } |
---|