Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Nov 1, 2008, 7:04:09 PM (16 years ago)
Author:
landauf
Message:

merged objecthierarchy branch back to trunk

Location:
code/trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • code/trunk

  • code/trunk/src/orxonox/gamestates/GSDedicated.cc

    r1790 r2087  
    3030#include "GSDedicated.h"
    3131
    32 #include <OgreRoot.h>
    33 #include <OgreSceneManager.h>
    34 #include "core/ConsoleCommand.h"
    3532#include "core/CommandLine.h"
    36 #include "core/Loader.h"
     33#include "core/Core.h"
    3734#include "network/Server.h"
    38 #include "objects/Tickable.h"
    39 #include "GraphicsEngine.h"
    40 #include "Settings.h"
    4135
    4236namespace orxonox
     
    4438    GSDedicated::GSDedicated()
    4539        : GameState<GSRoot>("dedicated")
    46         , timeFactor_(0)
    4740        , server_(0)
    48         , sceneManager_(0)
    49         , startLevel_(0)
    5041    {
    5142    }
     
    5748    void GSDedicated::enter()
    5849    {
    59         Settings::_getInstance().bHasServer_ = true;
     50        Core::setHasServer(true);
    6051
    61         // create Ogre SceneManager for the level
    62         this->sceneManager_ = Ogre::Root::getSingleton().createSceneManager(Ogre::ST_GENERIC, "LevelSceneManager");
    63         COUT(4) << "Created SceneManager: " << sceneManager_->getName() << std::endl;
     52        this->server_ = new network::Server(CommandLine::getValue("port"));
     53        COUT(0) << "Loading scene in server mode" << std::endl;
    6454
    65         // temporary hack
    66         GraphicsEngine::getInstance().setLevelSceneManager(this->sceneManager_);
    67 
    68         // reset game speed to normal
    69         timeFactor_ = 1.0f;
    70 
    71         int serverPort = CommandLine::getArgument<int>("port")->getValue();
    72         this->server_ = new network::Server(serverPort);
    73 
    74         // call the loader
    75         COUT(0) << "Loading level..." << std::endl;
    76         startLevel_ = new Level(Settings::getDataPath() + "levels/sample.oxw");
    77         Loader::open(startLevel_);
     55        GSLevel::enter(0);
    7856
    7957        server_->open();
    80 
    81         // add console commands
    82         FunctorMember01<GSDedicated, float>* functor = createFunctor(&GSDedicated::setTimeFactor);
    83         functor->setObject(this);
    84         CommandExecutor::addConsoleCommandShortcut(createConsoleCommand(functor, "setTimeFactor")).accessLevel(AccessLevel::Offline).defaultValue(0, 1.0);;
    8558    }
    8659
    8760    void GSDedicated::leave()
    8861    {
    89         // TODO: Remove and destroy console command
    90 
    91         Loader::unload(startLevel_);
    92         delete this->startLevel_;
     62        GSLevel::leave();
    9363
    9464        this->server_->close();
    9565        delete this->server_;
    9666
    97         Ogre::Root::getSingleton().destroySceneManager(this->sceneManager_);
    98 
    99         Settings::_getInstance().bHasServer_ = false;
     67        Core::setHasServer(false);
    10068    }
    10169
    10270    void GSDedicated::ticked(const Clock& time)
    10371    {
    104         // Call the scene objects
    105         for (ObjectList<Tickable>::iterator it = ObjectList<Tickable>::begin(); it; ++it)
    106             it->tick(time.getDeltaTime() * this->timeFactor_);
    107 
     72        GSLevel::ticked(time);
    10873        server_->tick(time.getDeltaTime());
    10974        this->tickChild(time);
    11075    }
    111 
    112     /**
    113     @brief
    114         Changes the speed of Orxonox
    115     */
    116     void GSDedicated::setTimeFactor(float factor)
    117     {
    118         this->timeFactor_ = factor;
    119     }
    12076}
Note: See TracChangeset for help on using the changeset viewer.