Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 3302


Ignore:
Timestamp:
Jul 18, 2009, 5:13:38 PM (15 years ago)
Author:
scheusso
Message:

changed some debug output
removed some uneccessary "multi"threading
some enhancements in Connection

Location:
code/branches/netp6/src/network
Files:
9 edited

Legend:

Unmodified
Added
Removed
  • code/branches/netp6/src/network/ClientInformation.h

    r3198 r3302  
    8787    static ClientInformation *findClient(ENetAddress *address, bool look_backwards=false);
    8888    static ClientInformation *getBegin(){return head_;}
     89    static bool hasClients(){ return ClientInformation::head_!=0; }
    8990
    9091    bool setSynched(bool s);
  • code/branches/netp6/src/network/Connection.cc

    r3214 r3302  
    3131#include <cassert>
    3232#include <enet/enet.h>
    33 #include <OgreTimer.h>
    3433#include "packet/Packet.h"
    3534
     
    7776   
    7877    assert(this->host_);
    79     Ogre::Timer timer;
    8078
    81     while( timer.getMilliseconds()<NETWORK_MAX_QUEUE_PROCESS_TIME && enet_host_service( this->host_, &event, NETWORK_WAIT_TIMEOUT ) > 0 )
     79    while( enet_host_service( this->host_, &event, NETWORK_WAIT_TIMEOUT ) > 0 )
    8280    {
    8381      switch(event.type){
  • code/branches/netp6/src/network/GamestateManager.cc

    r3240 r3302  
    9999
    100100  bool GamestateManager::processGamestates(){
     101    if( this->gamestateQueue.empty() )
     102        return true;
    101103    std::map<unsigned int, packet::Gamestate*>::iterator it;
    102104    // now push only the most recent gamestates we received (ignore obsolete ones)
     
    141143      int cid = temp->getID(); //get client id
    142144     
    143       packet::Gamestate *gs;
    144145      unsigned int gID = temp->getGamestateID();
    145146      if(!reference)
     
    242243
    243244    assert(curid==(unsigned int)GAMESTATEID_INITIAL || curid<gamestateID);
    244     COUT(4) << "acking gamestate " << gamestateID << " for clientid: " << clientID << " curid: " << curid << std::endl;
     245    COUT(5) << "acking gamestate " << gamestateID << " for clientid: " << clientID << " curid: " << curid << std::endl;
    245246    std::map<unsigned int, packet::Gamestate*>::iterator it;
    246247    for(it = gamestateMap_[clientID].begin(); it!=gamestateMap_[clientID].end() && it->first<gamestateID; ){
  • code/branches/netp6/src/network/Server.cc

    r3240 r3302  
    4949#include "core/ObjectList.h"
    5050#include "core/Executor.h"
    51 #include "core/ThreadPool.h"
    5251#include "packet/Chat.h"
    5352#include "packet/ClassID.h"
     
    7170  Server::Server() {
    7271    this->timeSinceLastUpdate_=0;
    73     this->threadPool_ = new ThreadPool();
    7472  }
    7573
     
    7775    this->setPort( port );
    7876    this->timeSinceLastUpdate_=0;
    79     this->threadPool_ = new ThreadPool();
    8077  }
    8178
     
    8986    this->setBindAddress( bindAddress );
    9087    this->timeSinceLastUpdate_=0;
    91     this->threadPool_ = new ThreadPool();
    9288  }
    9389
     
    9692  */
    9793  Server::~Server(){
    98     delete this->threadPool_;
    9994  }
    10095
     
    141136    // receive incoming packets
    142137    Connection::processQueue();
    143     // process incoming gamestates
    144     GamestateManager::processGamestates();
    145138   
    146     // pass sendFunctionCalls to worker thread pool
    147     ExecutorStatic* functioncalls = createExecutor( createFunctor(&FunctionCallManager::sendCalls) );
    148     this->threadPool_->passFunction( functioncalls, true );
    149    
    150     this->threadPool_->synchronise();
    151    
    152     //this steers our network frequency
    153     timeSinceLastUpdate_+=time.getDeltaTime();
    154     if(timeSinceLastUpdate_>=NETWORK_PERIOD)
     139    if ( ClientInformation::hasClients() )
    155140    {
    156       timeSinceLastUpdate_ -= static_cast<unsigned int>( timeSinceLastUpdate_ / NETWORK_PERIOD ) * NETWORK_PERIOD;
    157 //       ExecutorMember<GamestateManager>* updategamestate = createExecutor( createFunctor(&GamestateManager::updateGamestate);
    158 //       updategamestate->setObject( static_cast<GamestateManager*>(this) );
    159 //       this->threadPool_->passFunction( updategamestate );
    160       updateGamestate();
    161     }
    162     sendPackets(); // flush the enet queue
     141      // process incoming gamestates
     142      GamestateManager::processGamestates();
     143     
     144      // send function calls to clients
     145      FunctionCallManager::sendCalls();
     146     
     147      //this steers our network frequency
     148      timeSinceLastUpdate_+=time.getDeltaTime();
     149      if(timeSinceLastUpdate_>=NETWORK_PERIOD)
     150      {
     151        timeSinceLastUpdate_ -= static_cast<unsigned int>( timeSinceLastUpdate_ / NETWORK_PERIOD ) * NETWORK_PERIOD;
     152        updateGamestate();
     153      }
     154      sendPackets(); // flush the enet queue
     155    }
    163156  }
    164157
  • code/branches/netp6/src/network/Server.h

    r3240 r3302  
    7676    void syncClassid(unsigned int clientID);
    7777
    78     ThreadPool* threadPool_;
    7978    float timeSinceLastUpdate_;
    8079  };
  • code/branches/netp6/src/network/packet/ClassID.cc

    r3214 r3302  
    142142    classname = temp+2*sizeof(uint32_t);
    143143    id=ClassByString( std::string((const char*)classname) );
    144     COUT(0) << "processing classid: " << networkID << " name: " << classname << " id: " << id << std::endl;
     144    COUT(3) << "processing classid: " << networkID << " name: " << classname << " id: " << id << std::endl;
    145145    if(id==NULL){
    146146      COUT(0) << "Recieved a bad classname" << endl;
  • code/branches/netp6/src/network/packet/FunctionIDs.cc

    r3214 r3302  
    132132    stringsize = *(uint32_t*)(temp+sizeof(uint32_t));
    133133    functionname = temp+2*sizeof(uint32_t);
    134     COUT(0) << "processing functionid: " << networkID << " name: " << functionname << std::endl;
     134    COUT(3) << "processing functionid: " << networkID << " name: " << functionname << std::endl;
    135135    NetworkFunctionBase::setNetworkID((const char*)functionname, networkID);
    136136    temp += 2*sizeof(uint32_t) + stringsize;
  • code/branches/netp6/src/network/synchronisable/Synchronisable.cc

    r3240 r3302  
    9696      if (this->objectMode_ != 0x0 && (Host::running() && Host::isServer()))
    9797        deletedObjects_.push(objectID);
    98       // delete all Synchronisable Variables from syncList ( which are also in stringList )
    99       for(std::vector<SynchronisableVariableBase*>::iterator it = syncList.begin(); it!=syncList.end(); it++)
    100         delete (*it);
    101       syncList.clear();
    102       stringList.clear();
    103     }
     98    }
     99    // delete all Synchronisable Variables from syncList ( which are also in stringList )
     100    for(std::vector<SynchronisableVariableBase*>::iterator it = syncList.begin(); it!=syncList.end(); it++)
     101      delete (*it);
     102    syncList.clear();
     103    stringList.clear();
    104104    std::map<uint32_t, Synchronisable*>::iterator it;
    105105    it = objectMap_.find(objectID);
  • code/branches/netp6/src/network/synchronisable/SynchronisableSpecialisations.cc

    r3227 r3302  
    3838namespace orxonox{
    3939 
    40 //   template <> void Synchronisable::registerVariable( const std::string& variable, uint8_t mode, NetworkCallbackBase *cb, bool bidirectional)
    41 //   {
    42 //     if (bidirectional)
    43 //       syncList.push_back(new SynchronisableVariableBidirectional<const std::string>(variable, mode, cb));
    44 //     else
    45 //       syncList.push_back(new SynchronisableVariable<const std::string>(variable, mode, cb));
    46 //     stringList.push_back(syncList.back());
    47 //   }
    48  
    4940  template <> void Synchronisable::registerVariable( std::string& variable, uint8_t mode, NetworkCallbackBase *cb, bool bidirectional)
    5041  {
     42    SynchronisableVariableBase* sv;
    5143    if (bidirectional)
    52       syncList.push_back(new SynchronisableVariableBidirectional<const std::string>(variable, mode, cb));
     44      sv = new SynchronisableVariableBidirectional<const std::string>(variable, mode, cb);
    5345    else
    54       syncList.push_back(new SynchronisableVariable<const std::string>(variable, mode, cb));
    55     stringList.push_back(syncList.back());
     46      sv = new SynchronisableVariable<const std::string>(variable, mode, cb);
     47    syncList.push_back(sv);
     48    stringList.push_back(sv);
    5649  }
    5750 
Note: See TracChangeset for help on using the changeset viewer.