Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Jun 4, 2008, 8:54:43 PM (16 years ago)
Author:
rgrieder
Message:

merged input branch back to trunk

File:
1 edited

Legend:

Unmodified
Added
Removed
  • code/trunk/src/orxonox/Orxonox.cc

    r1534 r1535  
    2121 *
    2222 *   Author:
     23 *      Reto Grieder
     24 *   Co-authors:
    2325 *      Benjamin Knecht <beni_at_orxonox.net>, (C) 2007
    24  *   Co-authors:
    25  *      ...
    2626 *
    2727 */
     
    5757#include "core/Debug.h"
    5858#include "core/Loader.h"
    59 #include "core/Tickable.h"
    60 #include "core/InputManager.h"
     59#include "core/input/InputManager.h"
    6160#include "core/TclBind.h"
     61#include "core/Core.h"
    6262
    6363// audio
     
    7070// objects and tools
    7171#include "hud/HUD.h"
    72 #include <Ogre.h>
     72#include "objects/Tickable.h"
    7373
    7474#include "GraphicsEngine.h"
     75#include "Settings.h"
    7576
    7677// FIXME: is this really file scope?
    7778// globals for the server or client
    78 network::Client *client_g;
    79 network::Server *server_g;
     79network::Client *client_g = 0;
     80network::Server *server_g = 0;
    8081
    8182namespace orxonox
     
    166167   * @param path path to config (in home dir or something)
    167168   */
    168   bool Orxonox::init(int argc, char **argv, std::string path)
    169   {
    170     //TODO: find config file (assuming executable directory)
    171     //TODO: read config file
    172     //TODO: give config file to Ogre
     169  bool Orxonox::init(int argc, char **argv)
     170  {
     171#ifdef _DEBUG
     172    ConfigFileManager::getSingleton()->setFile(CFT_Settings, "orxonox_d.ini");
     173#else
     174    ConfigFileManager::getSingleton()->setFile(CFT_Settings, "orxonox.ini");
     175#endif
     176    Factory::createClassHierarchy();
     177
    173178    std::string mode;
    174     std::string dataPath;
     179    std::string tempDataPath;
    175180
    176181    ArgReader ar(argc, argv);
    177     ar.checkArgument("mode", mode, false);
    178     ar.checkArgument("data", dataPath, false);
    179     ar.checkArgument("ip", serverIp_, false);
    180     ar.checkArgument("port", serverPort_, false);
     182    ar.checkArgument("mode", &mode, false);
     183    ar.checkArgument("data", &tempDataPath, false);
     184    ar.checkArgument("ip",   &serverIp_, false);
     185    ar.checkArgument("port", &serverPort_, false);
    181186    if(ar.errorHandling())
     187    {
     188      COUT(1) << "Error while parsing command line arguments" << std::endl;
     189      COUT(1) << ar.getErrorString();
     190      COUT(0) << "Usage:" << std::endl << "orxonox [mode client|server|dedicated|standalone] "
     191        << "[--data PATH] [--ip IP] [--port PORT]" << std::endl;
    182192      return false;
     193    }
    183194
    184195    if (mode == "client")
     
    190201    else
    191202    {
    192       mode = "standalone";
     203      if (mode == "")
     204        mode = "standalone";
     205      if (mode != "standalone")
     206      {
     207        COUT(2) << "Warning: mode \"" << mode << "\" doesn't exist. "
     208          << "Defaulting to standalone" << std::endl;
     209        mode = "standalone";
     210      }
    193211      mode_ = STANDALONE;
    194212    }
    195213    COUT(3) << "Orxonox: Mode is " << mode << "." << std::endl;
     214
     215    if (tempDataPath != "")
     216    {
     217      if (tempDataPath[tempDataPath.size() - 1] != '/')
     218        tempDataPath += "/";
     219      Settings::tsetDataPath(tempDataPath);
     220    }
     221
     222    // initialise TCL
     223    TclBind::getInstance().setDataPath(Settings::getDataPath());
    196224
    197225    //if (mode_ == DEDICATED)
     
    202230    // procedure until the GUI is identical
    203231
    204     ConfigFileManager::getSingleton()->setFile(CFT_Settings, "orxonox.ini");
    205     Factory::createClassHierarchy();
    206 
    207232    ogre_ = &GraphicsEngine::getSingleton();
    208     if (!ogre_->setup(path))       // creates ogre root and other essentials
     233    if (!ogre_->setup())       // creates ogre root and other essentials
    209234      return false;
    210235
     
    421446      }
    422447
     448      // tick the core
     449      Core::tick((float)evt.timeSinceLastFrame);
    423450      // Call those objects that need the real time
    424451      for (Iterator<TickableReal> it = ObjectList<TickableReal>::start(); it; ++it)
     
    427454      for (Iterator<Tickable> it = ObjectList<Tickable>::start(); it; ++it)
    428455        it->tick((float)evt.timeSinceLastFrame * this->timefactor_);
     456      //AudioManager::tick();
     457      if (client_g)
     458        client_g->tick((float)evt.timeSinceLastFrame);
     459      if (server_g)
     460        server_g->tick((float)evt.timeSinceLastFrame);
    429461
    430462      // don't forget to call _fireFrameStarted in ogre to make sure
Note: See TracChangeset for help on using the changeset viewer.