Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 2758


Ignore:
Timestamp:
Mar 8, 2009, 4:40:01 PM (16 years ago)
Author:
scheusso
Message:

some cleanup (mostly comments)

Location:
code/branches/network/src/network
Files:
8 edited

Legend:

Unmodified
Added
Removed
  • code/branches/network/src/network/ConnectionManager.cc

    r2749 r2758  
    4646#include <boost/bind.hpp>
    4747
    48 // #include "core/CoreIncludes.h"
    49 // #include "core/BaseObject.h"
    50 // #include "core/Iterator.h"
    5148#include "util/Math.h"
    5249#include "util/Sleep.h"
     
    124121  void ConnectionManager::createListener() {
    125122    receiverThread_ = new boost::thread(boost::bind(&ConnectionManager::receiverThread, this));
    126     //network_threads.create_thread(boost::bind(boost::mem_fn(&ConnectionManager::receiverThread), this));
    127          //boost::thread thr(boost::bind(boost::mem_fn(&ConnectionManager::receiverThread), this));
    128123    return;
    129124  }
     
    131126  bool ConnectionManager::quitListener() {
    132127    quit=true;
    133     //network_threads.join_all();
    134128    receiverThread_->join();
    135129    return true;
     
    206200        // log handling ================
    207201        case ENET_EVENT_TYPE_CONNECT:
    208           //COUT(3) << "adding event_type_connect to queue" << std::endl;
    209202        case ENET_EVENT_TYPE_DISCONNECT:
    210           //addClient(event);
    211           //this is a workaround to ensure thread safety
    212           //COUT(5) << "Con.Man: connection event has occured" << std::endl;
    213           //break;
    214203        case ENET_EVENT_TYPE_RECEIVE:
    215           //std::cout << "received data" << std::endl;
    216           //COUT(5) << "Con.Man: receive event has occured" << std::endl;
    217           // only add, if client has connected yet and not been disconnected
    218           //if(head_->findClient(&event->peer->address))
    219204            processData(event);
    220205            event = new ENetEvent;
    221 //           else
    222 //             COUT(3) << "received a packet from a client we don't know" << std::endl;
    223206          break;
    224         //case ENET_EVENT_TYPE_DISCONNECT:
    225           //clientDisconnect(event->peer);
    226           //break;
    227207        case ENET_EVENT_TYPE_NONE:
    228208          //receiverThread_->yield();
     
    299279  }
    300280
    301   /**
    302    *
    303    * @param clientID
    304    */
    305 //   void ConnectionManager::syncClassid(unsigned int clientID) {
    306 //     unsigned int network_id=0, failures=0;
    307 //     std::string classname;
    308 //     Identifier *id;
    309 //     std::map<std::string, Identifier*>::const_iterator it = Factory::getFactoryMapBegin();
    310 //     while(it != Factory::getFactoryMapEnd()){
    311 //       id = (*it).second;
    312 //       if(id == NULL)
    313 //         continue;
    314 //       classname = id->getName();
    315 //       network_id = id->getNetworkID();
    316 //       if(network_id==0)
    317 //         COUT(3) << "we got a null class id: " << id->getName() << std::endl;
    318 //       COUT(4) << "Con.Man:syncClassid:\tnetwork_id: " << network_id << ", classname: " << classname << std::endl;
    319 //
    320 //       packet::ClassID *classid = new packet::ClassID( network_id, classname );
    321 //       classid->setClientID(clientID);
    322 //       while(!classid->send() && failures < 10){
    323 //         failures++;
    324 //       }
    325 //       ++it;
    326 //     }
    327 //     //sendPackets();
    328 //     COUT(4) << "syncClassid:\tall synchClassID packets have been sent" << std::endl;
    329 //   }
    330281
    331282  void ConnectionManager::syncClassid(unsigned int clientID) {
  • code/branches/network/src/network/ConnectionManager.h

    r2171 r2758  
    7676    static boost::recursive_mutex enet_mutex;
    7777    ConnectionManager();
    78     //ConnectionManager(ClientInformation *head);
    7978    ConnectionManager(int port);
    8079    ConnectionManager(int port, const char *address);
    8180    ConnectionManager(int port, const std::string& address);
    8281    ~ConnectionManager();
    83     //ENetPacket *getPacket(ENetAddress &address); // thread1
    84     //ENetPacket *getPacket(int &clientID);
    8582    ENetEvent *getEvent();
    8683    bool queueEmpty();
    8784    void createListener();
    8885    bool quitListener();
    89 //     bool addPacket(Packet::Packet *packet);
    9086    static bool addPacket(ENetPacket *packet, ENetPeer *peer);
    9187    static bool addPacket(ENetPacket *packet, int ID);
    9288    static bool addPacketAll(ENetPacket *packet);
    93   //  bool sendPackets(ENetEvent *event);
    9489    bool sendPackets();
    95     //bool createClient(int clientID);
    9690    void disconnectClient(ClientInformation *client);
    9791    void syncClassid(unsigned int clientID);
    9892
    9993  private:
    100 //     bool clientDisconnect(ENetPeer *peer);
    101 //     bool removeClient(int clientID);
    10294    bool processData(ENetEvent *event);
    103     //bool addClient(ENetEvent *event);
    10495    void receiverThread();
    10596    void disconnectClients();
  • code/branches/network/src/network/packet/ClassID.cc

    r2749 r2758  
    155155
    156156
    157 // uint32_t ClassID::getClassID(){
    158 //   return *(uint32_t *)(data_ + _CLASSID);
    159 // }
    160 
    161157} //namespace packet
    162158}//namespace orxonox
  • code/branches/network/src/network/packet/ClassID.h

    r2749 r2758  
    5252  bool process();
    5353
    54 //   uint32_t getClassID();
    55 //   uint32_t getClassNameLength(){ return classNameLength_; }
    56 //   const char *getClassName(){ return (const char*)(data_+_CLASSNAME); }
    5754private:
    58 //   uint32_t classNameLength_;
    59 //   static bool alreadySetOneClassID_;
    6055};
    6156
  • code/branches/network/src/network/packet/Gamestate.cc

    r2710 r2758  
    4848#define PACKET_FLAG_GAMESTATE  ENET_PACKET_FLAG_RELIABLE
    4949
    50 // Gamestate::Gamestate()
    51 // {
    52 //   flags_ = flags_ | PACKET_FLAG_GAMESTATE;
    53 // }
    5450
    5551Gamestate::Gamestate()
     
    127123#endif
    128124
    129     //if(it->doSelection(id))
    130125    if ( it->doSync( id, mode ) )
    131126      dataMap_.push_back( obj(it->getObjectID(), it->getCreatorID(), tempsize, mem-data_) );
    132 //     dataMap_[mem-data_]=(*it);  // save the mem location of the synchronisable data
    133127    if(!it->getData(mem, id, mode))
    134128      return false; // mem pointer gets automatically increased because of call by reference
     
    158152  assert(!header_->isDiffed());
    159153  uint8_t *mem=data_+GamestateHeader::getSize();
    160     // get the start of the Synchronisable list
    161   //ObjectList<Synchronisable>::iterator it=ObjectList<Synchronisable>::begin();
    162154  Synchronisable *s;
    163155
     
    177169        mem += objectheader.getDataSize();
    178170      }
    179 //         COUT(0) << "could not fabricate synchronisable: " << objectheader->objectID << " classid: " << objectheader->classID << " creator: " << objectheader->creatorID << endl;
    180 //       else
    181 //         COUT(0) << "fabricated: " << objectheader->objectID << " classid: " << objectheader->classID << " creator: "  << objectheader->creatorID << endl;
    182171    }
    183172    else
    184173    {
    185174      bool b = s->updateData(mem, mode);
    186 //      if(!b)
    187 //        COUT(0) << "data could not be updated" << endl;
    188175      assert(b);
    189176    }
     
    262249  uint8_t *ndata = new uint8_t[buffer+GamestateHeader::getSize()];
    263250  uint8_t *dest = ndata + GamestateHeader::getSize();
    264   //unsigned char *dest = new unsigned char[buffer];
    265251  uint8_t *source = data_ + GamestateHeader::getSize();
    266252  int retval;
     
    294280  uint32_t compsize = header_->getCompSize();
    295281  uint32_t bufsize;
    296 //  assert(compsize<=datasize);
    297282  bufsize = datasize;
    298283  assert(bufsize!=0);
     
    340325  assert(!header_->isDiffed());
    341326  GamestateHeader diffHeader(base->data_);
    342   //unsigned char *basep = base->getGs()/*, *gs = getGs()*/;
    343327  uint8_t *basep = GAMESTATE_START(base->data_), *gs = GAMESTATE_START(this->data_);
    344328  uint32_t of=0; // pointers offset
     
    397381  //copy in the zeros
    398382  for(it=dataMap_.begin(); it!=dataMap_.end();){
    399 //    if((*it).objSize==0)
    400 //      continue;
    401 //    if(it->second->getSize(HEADER->id)==0) // merged from objecthierarchy2, doesn't work anymore; TODO: change this
    402 //      continue;                            // merged from objecthierarchy2, doesn't work anymore; TODO: change this
    403383    SynchronisableHeader oldobjectheader(origdata);
    404384    SynchronisableHeader newobjectheader(newdata);
     
    408388      continue;
    409389    }
    410 //     object = Synchronisable::getSynchronisable( (*it).objID );
    411 //     assert(object->objectID == oldobjectheader->objectID);
    412390    objectsize = oldobjectheader.getDataSize();
    413391    objectOffset=SynchronisableHeader::getSize(); //skip the size and the availableData variables in the objectheader
     
    447425  assert(header_->isDiffed());
    448426  assert(!header_->isCompressed() && !base->header_->isCompressed());
    449   //unsigned char *basep = base->getGs()/*, *gs = getGs()*/;
    450427  uint8_t *basep = GAMESTATE_START(base->data_);
    451428  uint8_t *gs = GAMESTATE_START(this->data_);
  • code/branches/network/src/network/packet/Gamestate.h

    r2662 r2758  
    9393  private:
    9494    uint8_t *data_;
    95 //#define GAMESTATE_START(data) (data + sizeof(GamestateHeader))
    96 //#define GAMESTATE_HEADER(data) ((GamestateHeader *)data)
    97 //#define HEADER GAMESTATE_HEADER(data_)
    9895
    9996};
  • code/branches/network/src/network/synchronisable/Synchronisable.cc

    r2749 r2758  
    100100      if (this->objectMode_ != 0x0 && (Host::running() && Host::isServer()))
    101101        deletedObjects_.push(objectID);
    102 //       COUT(3) << "destruct synchronisable +++" << objectID << " | " << classID << std::endl;
    103 //       COUT(3) << " bump ---" << objectID << " | " << &objectMap_ << std::endl;
    104 //       assert(objectMap_[objectID]->objectID==objectID);
    105 //       objectMap_.erase(objectID);
    106102    }
    107103    std::map<uint32_t, Synchronisable*>::iterator it;
     
    110106      objectMap_.erase(it);
    111107
    112     //HACK HACK HACK HACK HACK HACK
    113     // this hack ensures that children of this object also get destroyed
    114 //     ObjectList<Synchronisable>::iterator it2, it3;
    115 //     // get total size of gamestate
    116 //     for(it2 = ObjectList<Synchronisable>::begin(); it2; ++it2)
    117 //     {
    118 //       if ( it2->getCreatorID() == this->objectID && it2->getCreatorID() != OBJECTID_UNKNOWN )
    119 //       {
    120 //         Synchronisable::deleteObject( it2->getObjectID() );
    121 //       }
    122 //     }
    123     //HACK HACK HACK HACK HACK HACK
    124108  }
    125109
     
    205189   */
    206190  bool Synchronisable::deleteObject(uint32_t objectID){
    207 //     assert(getSynchronisable(objectID));
    208191    if(!getSynchronisable(objectID))
    209192      return false;
    210193    assert(getSynchronisable(objectID)->objectID==objectID);
    211 //     delete objectMap_[objectID];
    212194    Synchronisable *s = getSynchronisable(objectID);
    213195    if(s)
     
    260242    if(!doSync(id, mode))
    261243      return true;
    262     //std::cout << "inside getData" << std::endl;
    263244    uint32_t tempsize = 0;
    264245    if (this->classID==0)
     
    269250
    270251    assert(this->classID==this->getIdentifier()->getNetworkID());
    271 //     this->classID=this->getIdentifier()->getNetworkID(); // TODO: correct this
    272252    std::list<SynchronisableVariableBase*>::iterator i;
    273253    uint32_t size;
     
    307287      mode=state_;
    308288    std::list<SynchronisableVariableBase *>::iterator i;
    309     //assert(objectMode_!=0x0);
    310     //assert( (mode ^ objectMode_) != 0);
    311289    if(syncList.empty()){
    312290      assert(0);
  • code/branches/network/src/network/synchronisable/Synchronisable.h

    r2710 r2758  
    142142  protected:
    143143    Synchronisable(BaseObject* creator);
    144 //     void registerVariable(void *var, int size, variableType t, uint8_t mode=0x1, NetworkCallbackBase *cb=0);
    145144    template <class T> void registerVariable(T& variable, uint8_t mode=0x1, NetworkCallbackBase *cb=0, bool bidirectional=false);
    146145    template <class T> void unregisterVariable(T& var);
     
    205204  template <> _NetworkExport void Synchronisable::registerVariable( const Quaternion& variable, uint8_t mode, NetworkCallbackBase* cb, bool bidirectional);
    206205  template <> _NetworkExport void Synchronisable::registerVariable( Quaternion& variable, uint8_t mode, NetworkCallbackBase* cb, bool bidirectional);
    207 //   template <> _NetworkExport void Synchronisable::registerVariable( LODParticle::LOD& variable, uint8_t mode, NetworkCallbackBase* cb, bool bidirectional);
    208 //   template <> _NetworkExport void Synchronisable::registerVariable( Ogre::Light::LightTypes& variable, uint8_t mode, NetworkCallbackBase* cb, bool bidirectional);
    209206}
    210207
Note: See TracChangeset for help on using the changeset viewer.