Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Dec 12, 2008, 10:10:31 AM (16 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
Location:
code/branches/presentation/src
Files:
12 edited

Legend:

Unmodified
Added
Removed
  • code/branches/presentation/src/network/NetworkPrereqs.h

    r2371 r2415  
    7373  static const unsigned int CLIENTID_UNKNOWN = (unsigned int)-2;
    7474  static const uint32_t OBJECTID_UNKNOWN = static_cast<uint32_t>(-1);
    75   static const unsigned int SCHED_PRIORITY_OFFSET = -5;
    7675
    7776 
  • code/branches/presentation/src/network/Server.cc

    r2171 r2415  
    6363{
    6464  const unsigned int MAX_FAILURES = 20;
    65   const unsigned int NETWORK_FREQUENCY = 25;
    66   const float NETWORK_PERIOD = (float)1/NETWORK_FREQUENCY;
    6765
    6866  /**
  • code/branches/presentation/src/network/Server.h

    r2171 r2415  
    5252{
    5353  const int CLIENTID_SERVER = 0;
     54  const unsigned int NETWORK_FREQUENCY = 25;
     55  const float NETWORK_PERIOD = 1./NETWORK_FREQUENCY;
    5456
    5557  /**
  • code/branches/presentation/src/network/TrafficControl.cc

    r2413 r2415  
    3636
    3737namespace orxonox {
     38 
     39  static const unsigned int SCHED_PRIORITY_OFFSET = -1;
    3840
    3941  objInfo::objInfo(uint32_t ID, uint32_t creatorID, int32_t curGsID, int32_t diffGsID, uint32_t size, unsigned int prioperm, unsigned int priosched)
     
    256258    {
    257259      assert( (*itvec).objSize < 1000);
    258 //       COUT(0) << "==targetsize==  " << targetsize << endl;
    259260      if ( ( size + (*itvec).objSize ) < targetsize )
    260261      {
    261 //         COUT(0) << "no cut" << endl;
    262262        size += (*itvec).objSize;//objSize is given in bytes
    263263        ++itvec;
     
    265265      else
    266266      {
    267         COUT(0) << "cut" << endl;
    268267        clientListPerm_[currentClientID][(*itvec).objID].objValueSched += SCHED_PRIORITY_OFFSET; // NOTE: SCHED_PRIORITY_OFFSET is negative
    269 //         ittemp = itvec;
    270268        list->erase(itvec++);
    271 //         itvec = ittemp;
    272269      }
    273270//       printList(list, currentClientID);
  • code/branches/presentation/src/network/synchronisable/Synchronisable.cc

    r2371 r2415  
    6666    RegisterRootObject(Synchronisable);
    6767    static uint32_t idCounter=0;
    68     objectFrequency_=1;
    6968    objectMode_=0x1; // by default do not send data to server
    7069    if ( !Host::running() || ( Host::running() && Host::isServer() ) )
     
    7877    classID = static_cast<uint32_t>(-1);
    7978
    80 
     79    // set standard priority
     80    this->setPriority( priority::normal );
     81
     82   
     83    // get creator id
    8184#ifndef NDEBUG
    8285    ObjectList<Synchronisable>::iterator it;
  • code/branches/presentation/src/network/synchronisable/Synchronisable.h

    r2371 r2415  
    6161    };
    6262  }
     63 
     64  namespace priority{
     65    enum prio{
     66      very_high   = -30,
     67      high        = -15,
     68      normal      = 0,
     69      low         = 15,
     70      very_low    = 30
     71    };
     72  }
    6373
    6474  struct _NetworkExport synchronisableHeader{
     
    101111    template <class T> void unregisterVariable(T& var);
    102112    void setObjectMode(uint8_t mode);
    103     void setObjectPriority(unsigned int freq){ objectFrequency_ = freq; }
     113    void setPriority(unsigned int freq){ objectFrequency_ = freq; }
    104114
    105115
  • 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}
  • code/branches/presentation/src/orxonox/gamestates/GSDedicated.h

    r2171 r2415  
    4949
    5050        Server*      server_;
     51        float        timeSinceLastUpdate_;
    5152    };
    5253}
  • code/branches/presentation/src/orxonox/objects/worldentities/ControllableEntity.cc

    r2371 r2415  
    6666        this->server_orientation_ = Quaternion::IDENTITY;
    6767        this->client_orientation_ = Quaternion::IDENTITY;
     68       
     69        this->setPriority( priority::very_high );
    6870
    6971        this->registerVariables();
  • code/branches/presentation/src/orxonox/objects/worldentities/Model.cc

    r2371 r2415  
    4040    Model::Model(BaseObject* creator) : PositionableEntity(creator)
    4141    {
    42         static unsigned int i=10;
    4342        RegisterObject(Model);
    4443
    4544        this->registerVariables();
    46         this->setObjectPriority(i++);
    4745    }
    4846
  • code/branches/presentation/src/orxonox/objects/worldentities/MovableEntity.cc

    r2371 r2415  
    5353        this->overwrite_position_ = Vector3::ZERO;
    5454        this->overwrite_orientation_ = Quaternion::IDENTITY;
     55       
     56        this->setPriority( priority::low );
    5557
    5658        this->registerVariables();
  • code/branches/presentation/src/orxonox/objects/worldentities/PositionableEntity.cc

    r2371 r2415  
    3838    {
    3939        RegisterObject(PositionableEntity);
     40       
     41        this->setPriority( priority::very_low );
    4042
    4143        this->registerVariables();
Note: See TracChangeset for help on using the changeset viewer.