Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Dec 12, 2008, 10:10:31 AM (15 years ago)
Author:
scheusso
Message:
  • adjusted some priorities of objects (movableentity, controllableentity, positionableentity, model)
  • dedicated server mode doesn't consume 100%cpu load anymore now
File:
1 edited

Legend:

Unmodified
Added
Removed
  • code/branches/presentation/src/orxonox/gamestates/GSDedicated.cc

    r2171 r2415  
    3535#include "network/Server.h"
    3636#include "objects/Tickable.h"
     37#include "util/Sleep.h"
    3738
    3839namespace orxonox
     
    4142        : GameState<GSRoot>("dedicated")
    4243        , server_(0)
     44        , timeSinceLastUpdate_(0)
    4345    {
    4446    }
     
    7274    void GSDedicated::ticked(const Clock& time)
    7375    {
    74         GSLevel::ticked(time);
    75         server_->tick(time.getDeltaTime());
    76         this->tickChild(time);
     76//         static float startTime = time.getSecondsPrecise();
     77//         static int nrOfTicks = 0;
     78        timeSinceLastUpdate_+=time.getDeltaTime();
     79        if(timeSinceLastUpdate_>=NETWORK_PERIOD){
     80//             ++nrOfTicks;
     81//             COUT(0) << "estimated ticks/sec: " << nrOfTicks/(time.getSecondsPrecise()-startTime) << endl;
     82            timeSinceLastUpdate_ -= static_cast<unsigned int>( timeSinceLastUpdate_ / NETWORK_PERIOD ) * NETWORK_PERIOD;
     83            GSLevel::ticked(time);
     84            server_->tick(time.getDeltaTime());
     85            this->tickChild(time);
     86        }
     87        else
     88        {
     89            usleep( (int)( (NETWORK_PERIOD - timeSinceLastUpdate_)*1000*1000 ) );
     90//             COUT(0) << "sleeping for " << (int)( (NETWORK_PERIOD - timeSinceLastUpdate_)*1000*1000 ) << " usec" << endl;
     91        }
    7792    }
    7893}
Note: See TracChangeset for help on using the changeset viewer.