Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 4122 in orxonox.OLD for orxonox/branches/heightMap/src/orxonox.cc


Ignore:
Timestamp:
May 9, 2005, 11:29:19 AM (20 years ago)
Author:
bensch
Message:

orxonox/branches/heightMap: merged the Trunk back into branches/heightMap:
merged with Command
svn merge -r 3918:HEAD trunk branches/heightMap
conflicts resolved in favor of the Trunk

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
  • orxonox/branches/heightMap/src/orxonox.cc

    r3790 r4122  
    2222   main-programmer: Patrick Boenzli
    2323   co-programmer: Christian Meyer
    24    co-programmer: Benjamin Grauer: injected ResourceManager/GraphicsEngine
     24   co-programmer: Benjamin Grauer: injected ResourceManager/GraphicsEngine/GUI
    2525*/
    2626
    2727#include "orxonox.h"
     28
     29#include "gui.h"
    2830
    2931#include "world.h"
    3032#include "data_tank.h"
    3133#include "command_node.h"
     34#include "ini_parser.h"
    3235#include "game_loader.h"
    3336#include "graphics_engine.h"
    3437#include "resource_manager.h"
    3538#include "text_engine.h"
     39#include "factory.h"
    3640
    3741#include <string.h>
    38 int verbose = 3;
     42
     43int verbose = 4;
    3944
    4045using namespace std;
     
    4550Orxonox::Orxonox ()
    4651{
    47   pause = false;
     52  this->pause = false;
     53
     54  this->world = NULL;
     55  this->resources = NULL;
     56  this->localinput = NULL;
    4857}
    4958
     
    5362Orxonox::~Orxonox ()
    5463{
     64  int i =0;
    5565  Orxonox::singletonRef = NULL;
    5666  if( world != NULL) delete world;
    57   if( localinput != NULL) delete world;
     67  if( localinput != NULL) delete localinput;
    5868  if( resources != NULL) delete resources;
    5969  delete GraphicsEngine::getInstance(); // deleting the Graphics
     
    8494void Orxonox::getConfigFile (int argc, char** argv)
    8595{
    86   strcpy (configfilename, "orxonox.conf");
     96  strcpy (configfilename, "~/.orxonox/orxonox.conf");
    8797}
    8898
     
    98108  SDL_Init (SDL_INIT_TIMER);
    99109  // initialize everything
     110  printf("> Initializing resources\n");
     111  if( initResources () == -1) return -1;
     112
    100113  if( initVideo() == -1) return -1;
    101114  if( initSound() == -1) return -1;
     
    104117  printf("> Initializing networking\n");
    105118  if( initNetworking () == -1) return -1;
    106   printf("> Initializing resources\n");
    107   if( initResources () == -1) return -1;
    108119  //printf("> Initializing world\n");
    109120  //if( init_world () == -1) return -1; PB: world will be initialized when started
     
    143154{
    144155  // create localinput
    145   localinput = new CommandNode( configfilename);
     156  localinput = new CommandNode(configfilename);
    146157 
    147158  return 0;
     
    164175int Orxonox::initResources()
    165176{
    166   //  printf("Not yet implemented\n");
    167177  PRINT(3)("initializing ResourceManager\n");
    168178  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
    171219  PRINT(3)("initializing TextEngine\n");
    172220  TextEngine::getInstance();
     
    200248 
    201249  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);
    203252  this->gameLoader->init();
    204253  this->gameLoader->start();
     
    279328
    280329
     330bool showGui = false;
    281331
    282332/**
     
    300350
    301351  int i;
    302   for(i = 0; i < argc; ++i)
     352  for(i = 1; i < argc; ++i)
    303353    {
    304354      if(! strcmp( "--help", argv[i])) return startHelp();
    305355      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
    309360  return startOrxonox(argc, argv);
    310361}
     
    314365int startHelp()
    315366{
    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");
    321373}
    322374
     
    324376int startOrxonox(int argc, char** argv)
    325377{
    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
    327398  Orxonox *orx = Orxonox::getInstance();
    328399 
    329400  if((*orx).init(argc, argv) == -1)
    330401    {
    331       printf("! Orxonox initialization failed\n");
     402      PRINTF(1)("! Orxonox initialization failed\n");
    332403      return -1;
    333404    }
     
    336407 
    337408  delete orx;
     409  ResourceManager::deleteFile("~/.orxonox/orxonox.lock");
    338410 
    339411}
     
    346418#include "player.h"
    347419#include "base_object.h"
     420
    348421#include <asm/msr.h>
    349422#include <linux/timex.h>
Note: See TracChangeset for help on using the changeset viewer.