Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Dec 16, 2008, 6:01:13 PM (15 years ago)
Author:
landauf
Message:

Merged objecthierarchy2 into presentation branch

Couln't merge 2 lines in Gamestate.cc and a whole block of code in GSDedicated.cc (it seems like oli implemented in both branches something like a network-tick-limiter but with different approaches)

Not yet tested in network mode and with bots
The SpaceShips movement is also not yet fully adopted to the new physics (see Engine class)

Location:
code/branches/presentation
Files:
10 edited

Legend:

Unmodified
Added
Removed
  • code/branches/presentation

  • code/branches/presentation/src/network/GamestateClient.cc

    r2371 r2485  
    8282    NetworkCallbackManager::callCallbacks();
    8383   
    84     if (!processed)
    85         return false;
     84    if (!processed){
     85      sendAck(0);
     86      return false;
     87    }
    8688    //successfully loaded data from gamestate. now save gamestate for diff and delete the old gs
    8789    tempGamestate_=NULL;
  • code/branches/presentation/src/network/GamestateManager.cc

    r2382 r2485  
    5151#include "synchronisable/Synchronisable.h"
    5252#include "synchronisable/NetworkCallbackManager.h"
     53#include "packet/Acknowledgement.h"
    5354
    5455namespace orxonox
     
    172173    unsigned int curid = temp->getGamestateID();
    173174
    174     if(gamestateID == 0){
     175    if(gamestateID == ACKID_NACK){
    175176      temp->setGamestateID(GAMESTATEID_INITIAL);
    176177      return true;
  • code/branches/presentation/src/network/TrafficControl.cc

    r2436 r2485  
    3636
    3737namespace orxonox {
    38  
    39   static const unsigned int SCHED_PRIORITY_OFFSET = -1;
     38
     39  static const unsigned int SCHED_PRIORITY_OFFSET = (unsigned int)-1;
    4040
    4141  objInfo::objInfo(uint32_t ID, uint32_t creatorID, int32_t curGsID, int32_t diffGsID, uint32_t size, unsigned int prioperm, unsigned int priosched)
    42   { 
    43     objID = ID; objCreatorID = creatorID; objCurGS = curGsID; objDiffGS = diffGsID; objSize = size; objValuePerm = prioperm; objValueSched = priosched; 
    44   }
    45  
     42  {
     43    objID = ID; objCreatorID = creatorID; objCurGS = curGsID; objDiffGS = diffGsID; objSize = size; objValuePerm = prioperm; objValueSched = priosched;
     44  }
     45
    4646  objInfo::objInfo()
    47   { 
    48     objID = OBJECTID_UNKNOWN; objCreatorID = OBJECTID_UNKNOWN; objCurGS = GAMESTATEID_INITIAL; objDiffGS = objCurGS; objSize = 0; objValuePerm = 0; objValueSched = 0; 
    49   }
    50  
    51  
    52  
     47  {
     48    objID = OBJECTID_UNKNOWN; objCreatorID = OBJECTID_UNKNOWN; objCurGS = GAMESTATEID_INITIAL; objDiffGS = objCurGS; objSize = 0; objValuePerm = 0; objValueSched = 0;
     49  }
     50
     51
     52
    5353  obj::obj()
    54   { 
    55     objID = OBJECTID_UNKNOWN; objCreatorID = OBJECTID_UNKNOWN; objSize = 0; objDataOffset = 0; 
     54  {
     55    objID = OBJECTID_UNKNOWN; objCreatorID = OBJECTID_UNKNOWN; objSize = 0; objDataOffset = 0;
    5656  }
    5757  obj::obj( uint32_t ID, uint32_t creatorID, uint32_t size, uint32_t offset )
     
    5959    objID = ID; objCreatorID = creatorID; objSize = size; objDataOffset = offset;
    6060  }
    61  
     61
    6262/**
    6363*Initializing protected members
    6464*/
    6565        TrafficControl *TrafficControl::instance_=0;
    66        
     66
    6767        /**
    6868        * @brief Constructor: assures that only one reference will be created and sets the pointer
     
    7575    this->setConfigValues();
    7676        }
    77        
     77
    7878        /**
    7979        * @brief Destructor: resets the instance pointer to 0
     
    9393    SetConfigValue ( targetSize, 5000 );
    9494  }
    95  
     95
    9696  /**
    9797  * sort-algorithm for sorting the objectlist after priorities
     
    102102    assert(clientListPerm_[clientID].find(i.objID) != clientListPerm_[clientID].end()); // make sure the object i is in the client list
    103103    assert(clientListPerm_[clientID].find(j.objID) != clientListPerm_[clientID].end()); // make sure the object j is in the client list
    104    
     104
    105105    int prio1 = clientListPerm_[clientID][i.objID].objValuePerm + clientListPerm_[clientID][i.objID].objValueSched;
    106106    int prio2 = clientListPerm_[clientID][j.objID].objValuePerm + clientListPerm_[clientID][j.objID].objValueSched;
     
    118118  }
    119119
    120  
     120
    121121
    122122        void TrafficControl::processObjectList(unsigned int clientID, unsigned int gamestateID, std::list<obj> *list)
     
    128128          return;
    129129        }
    130  
     130
    131131  TrafficControl *TrafficControl::getInstance()
    132132  {
     
    134134    return instance_;
    135135  }
    136        
     136
    137137        void TrafficControl::ack(unsigned int clientID, unsigned int gamestateID)
    138138        {
    139139          std::list<obj>::iterator itvec;  // iterator to iterate through the acked objects
    140    
     140
    141141    //assertions to make sure the maps already exist
    142142    assert(clientListTemp_.find(clientID) != clientListTemp_.end() );
    143143    assert(clientListPerm_.find(clientID) != clientListPerm_.end() );
    144144          assert( clientListTemp_[clientID].find(gamestateID) != clientListTemp_[clientID].end() );
    145    
     145
    146146    for(itvec = clientListTemp_[clientID][gamestateID].begin(); itvec != clientListTemp_[clientID][gamestateID].end(); itvec++)
    147147          {
     
    173173        */
    174174        void TrafficControl::insertinClientListPerm(unsigned int clientID, obj objinf)
    175         { 
     175        {
    176176          std::map<unsigned int,std::map<unsigned int, objInfo> >::iterator itperm;//iterator clientListPerm over clientIDs
    177177//        itperm = (clientListPerm_).find(clientID);
     
    182182//     permObjPrio_.insert(objid, objinf.objValuePerm);
    183183        }
    184        
     184
    185185  /**
    186186  * updateClientListTemp
    187187  * takes the shortened list which will be sent to the gsmanager and puts the *info into clientListTemp
    188   */   
     188  */
    189189  void TrafficControl::updateClientListTemp(std::list<obj> *list)
    190190  {
     
    225225        void TrafficControl::evaluateList(unsigned int clientID, std::list<obj> *list)
    226226        {
    227        
     227
    228228          //now the sorting
    229        
     229
    230230          //compare listToProcess vs clientListPerm
    231231    //if listToProcess contains new Objects, add them to clientListPerm
     
    248248    }
    249249          //end compare listToProcess vs clientListPerm
    250    
     250
    251251    if( bActive_ )
    252252    {
     
    254254      // use boost bind here because we need to pass a memberfunction to stl sort
    255255      list->sort(boost::bind(&TrafficControl::prioritySort, this, clientID, _1, _2) );
    256      
     256
    257257      //now we check, that the creator of an object always exists on a client
    258258      std::list<obj>::iterator itcreator;
    259259      for(itvec = list->begin(); itvec != list->end(); itvec++)
    260       { 
     260      {
    261261        fixCreatorDependencies(itvec, list, clientID);
    262262      }
    263263      //end of sorting
    264       //now the cutting, work the same obj out in processobjectlist and copiedlist, compression rate muss noch festgelegt werden. 
     264      //now the cutting, work the same obj out in processobjectlist and copiedlist, compression rate muss noch festgelegt werden.
    265265//       printList(list, clientID);
    266266      cut(list, targetSize);
    267      
     267
    268268      //now sort again after objDataOffset
    269269      list->sort(boost::bind(&TrafficControl::dataSort, this, _1, _2) );
     
    281281      COUT(0) << "ObjectID: " << (*it).objID << " creatorID: " << (*it).objCreatorID << " Priority: " << clientListPerm_[clientID][(*it).objID].objValuePerm + clientListPerm_[clientID][(*it).objID].objValueSched << " size: " << (*it).objSize << endl;
    282282  }
    283  
     283
    284284  void TrafficControl::fixCreatorDependencies(std::list<obj>::iterator it1, std::list<obj> *list, unsigned int clientID)
    285285  {
     
    301301    }
    302302  }
    303  
     303
    304304  void TrafficControl::clientDisconnected(unsigned int clientID)
    305305  {
  • code/branches/presentation/src/network/packet/Acknowledgement.h

    r2171 r2485  
    3232#include "Packet.h"
    3333
     34const unsigned int ACKID_NACK = 0;
    3435
    3536namespace orxonox {
  • code/branches/presentation/src/network/packet/Gamestate.cc

    r2476 r2485  
    3131#include "../synchronisable/Synchronisable.h"
    3232#include "../TrafficControl.h"
     33#include "core/Core.h"
    3334#include "core/CoreIncludes.h"
    3435#include "core/Iterator.h"
     
    151152    if(!s)
    152153    {
    153       Synchronisable::fabricate(mem, mode);
     154      if (!Core::isMaster())
     155        Synchronisable::fabricate(mem, mode);
     156      else
     157        mem += objectheader->size;
    154158//         COUT(0) << "could not fabricate synchronisable: " << objectheader->objectID << " classid: " << objectheader->classID << " creator: " << objectheader->creatorID << endl;
    155159//       else
     
    170174      if (it->objectMode_ != 0x0) {
    171175        COUT(0) << "Found object with OBJECTID_UNKNOWN on the client with objectMode != 0x0!" << std::endl;
     176        COUT(0) << "Possible reason for this error: Client created a synchronized object without the Server's approval." << std::endl;
    172177        assert(false);
    173178      }
     
    384389  //call TrafficControl
    385390  TrafficControl::getInstance()->processObjectList( clientID, HEADER->id, &dataMap_ );
    386  
     391
    387392  //copy in the zeros
    388393  for(it=dataMap_.begin(); it!=dataMap_.end();){
    389394//    if((*it).objSize==0)
    390395//      continue;
     396//    if(it->second->getSize(HEADER->id)==0) // merged from objecthierarchy2, doesn't work anymore; TODO: change this
     397//      continue;                            // merged from objecthierarchy2, doesn't work anymore; TODO: change this
    391398    oldobjectheader = (synchronisableHeader*)origdata;
    392399    newobjectheader = (synchronisableHeader*)newdata;
  • code/branches/presentation/src/network/packet/Packet.cc

    r2171 r2485  
    129129      return false;
    130130    }
    131     // Assures we don't create a packet and destroy it right after in another thread
    132     // without having a reference in the packetMap_
    133     boost::recursive_mutex::scoped_lock lock(Packet::packetMap_mutex);
    134131    // We deliver ENet the data address so that it doesn't memcpy everything again.
    135132    // --> We have to delete data_ ourselves!
     
    138135    // Add the packet to a global list so we can access it again once enet calls our
    139136    // deletePacket method. We can of course only give a one argument function to the ENet C library.
    140     packetMap_[(size_t)(void*)enetPacket_] = this;
     137    {
     138      // Assures we don't create a packet and destroy it right after in another thread
     139      // without having a reference in the packetMap_
     140      boost::recursive_mutex::scoped_lock lock(Packet::packetMap_mutex);
     141      packetMap_[(size_t)(void*)enetPacket_] = this;
     142    }
    141143  }
    142144#ifndef NDEBUG
  • code/branches/presentation/src/network/packet/Welcome.cc

    r2483 r2485  
    4343#define _CLIENTID             _PACKETID + sizeof(ENUM::Type)
    4444#define _ENDIANTEST           _CLIENTID + sizeof(uint32_t)
    45  
     45
    4646  Welcome::Welcome( uint32_t clientID, uint32_t shipID )
    4747 : Packet()
     
    7474
    7575bool Welcome::process(){
    76   uint32_t shipID, clientID;
     76  uint32_t clientID;
    7777  clientID = *(uint32_t *)(data_ + _CLIENTID );
    7878  assert(*(uint32_t *)(data_ + _ENDIANTEST ) == 0xFEDC4321);
  • code/branches/presentation/src/network/synchronisable/Synchronisable.cc

    r2482 r2485  
    119119    if (it != objectMap_.end())
    120120      objectMap_.erase(it);
    121    
     121
    122122    //HACK HACK HACK HACK HACK HACK
    123123    // this hack ensures that childs of this object also get destroyed
     
    166166
    167167    Identifier* id = ClassByID(header->classID);
     168    if (!id)
     169    {
     170        COUT(0) << "Assertion failed: id" << std::endl;
     171        COUT(0) << "Possible reason for this error: Client received a synchronizable object whose class has no factory." << std::endl;
     172        abort();
     173    }
    168174    assert(id);
    169175    BaseObject* creator = 0;
     
    253259
    254260/*  void Synchronisable::registerVariable(void *var, int size, variableType t, uint8_t mode, NetworkCallbackBase *cb){
    255     assert( mode==direction::toclient || mode==direction::toserver || mode==direction::serverMaster || mode==direction::clientMaster);
     261    assert( mode==variableDirection::toclient || mode==variableDirection::toserver || mode==variableDirection::serverMaster || mode==variableDirection::clientMaster);
    256262    // create temporary synch.Var struct
    257263    synchronisableVariable *temp = new synchronisableVariable;
     
    261267    temp->type = t;
    262268    temp->callback = cb;
    263     if( ( mode & direction::bidirectional ) )
     269    if( ( mode & variableDirection::bidirectional ) )
    264270    {
    265271      if(t!=STRING)
     
    286292#endif
    287293  }*/
    288  
     294
    289295
    290296  /**
     
    444450    objectMode_=mode;
    445451  }
    446  
     452
    447453
    448454}
  • code/branches/presentation/src/network/synchronisable/Synchronisable.h

    r2459 r2485  
    6161    };
    6262  }
    63  
     63
    6464  namespace priority{
    6565    enum prio{
     
    100100    static uint32_t popDeletedObject(){ uint32_t i = deletedObjects_.front(); deletedObjects_.pop(); return i; }
    101101
    102     inline uint32_t getObjectID(){return objectID;}
    103     inline unsigned int getCreatorID(){return creatorID;}
    104     inline uint32_t getClassID(){return classID;}
    105     inline unsigned int getPriority(){ return objectFrequency_;}
     102    inline uint32_t getObjectID() const {return objectID;}
     103    inline unsigned int getCreatorID() const {return creatorID;}
     104    inline uint32_t getClassID() const {return classID;}
     105    inline unsigned int getPriority() const { return objectFrequency_;}
    106106
    107107  protected:
     
    134134    static std::queue<uint32_t> deletedObjects_;
    135135  };
    136  
     136
    137137  template <class T> void Synchronisable::registerVariable(T& variable, uint8_t mode, NetworkCallbackBase *cb, bool bidirectional)
    138138  {
     
    158158    // the variable has not been registered before
    159159  }
    160  
     160
    161161  // ================= Specialisation declarations
    162162  template <> _NetworkExport void Synchronisable::registerVariable( const ColourValue& variable, uint8_t mode, NetworkCallbackBase* cb, bool bidirectional);
Note: See TracChangeset for help on using the changeset viewer.