Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 2355


Ignore:
Timestamp:
Dec 8, 2008, 8:36:27 PM (16 years ago)
Author:
scheusso
Message:

merged network branch to network64 branch
not everything working yet (trafficcontrol)

Location:
code/branches/network64/src
Files:
2 added
10 edited

Legend:

Unmodified
Added
Removed
  • code/branches/network64/src/network/CMakeLists.txt

    r2211 r2355  
    1111  PacketBuffer.cc
    1212  Server.cc
     13  TrafficControl.cc
    1314  Host.cc
    1415)
  • code/branches/network64/src/network/ClientInformation.cc

    r2171 r2355  
    4545namespace orxonox
    4646{
     47 
    4748
    4849  ClientInformation *ClientInformation::head_=0;
  • code/branches/network64/src/network/ClientInformation.h

    r2171 r2355  
    4646#include <boost/thread/recursive_mutex.hpp>
    4747
     48
    4849// WATCH OUT: THE CLIENTINFORMATION LIST IS NOT THREADSAFE ANYMORE
    4950
    5051namespace orxonox
    5152{
    52   static const unsigned int GAMESTATEID_INITIAL = (unsigned int)-1;
    53   static const unsigned int CLIENTID_UNKNOWN = (unsigned int)-2;
    5453
    5554  /**
  • code/branches/network64/src/network/GamestateManager.cc

    r2309 r2355  
    137137    if(!reference)
    138138      return 0;
    139     gs = reference->doSelection(clientID);
    140 //     gs = new packet::Gamestate(*reference);
     139    gs = reference->doSelection(clientID, 10000);
    141140//     gs = new packet::Gamestate(*reference);
    142141    // save the (undiffed) gamestate in the clients gamestate map
  • code/branches/network64/src/network/NetworkPrereqs.h

    r2309 r2355  
    5757
    5858//-----------------------------------------------------------------------
     59// Includes
     60//-----------------------------------------------------------------------
     61#include "util/Math.h"
     62
     63
     64//-----------------------------------------------------------------------
    5965// Forward declarations
    6066//-----------------------------------------------------------------------
    6167namespace orxonox
    6268{
     69
     70// Constants definition
     71
     72  static const unsigned int GAMESTATEID_INITIAL = (unsigned int)-1;
     73  static const unsigned int CLIENTID_UNKNOWN = (unsigned int)-2;
     74  static const uint32_t OBJECTID_UNKNOWN = static_cast<uint32_t>(-1);
     75  static const unsigned int SCHED_PRIORITY_OFFSET = -5;
     76
     77 
     78
     79 
    6380  class Client;
    6481  class ClientConnection;
     
    84101  struct QueueItem;
    85102  struct syncData;
     103  class obj;
     104  class objInfo;
    86105  namespace packet{
    87106    class Gamestate;
  • code/branches/network64/src/network/packet/Gamestate.cc

    r2309 r2355  
    2828
    2929#include "Gamestate.h"
    30 #include "network/ClientInformation.h"
    31 #include "network/GamestateHandler.h"
     30#include "../GamestateHandler.h"
     31#include "../synchronisable/Synchronisable.h"
     32#include "../TrafficControl.h"
    3233#include "core/CoreIncludes.h"
    3334#include "core/Iterator.h"
     
    4849
    4950#define PACKET_FLAG_GAMESTATE  ENET_PACKET_FLAG_RELIABLE
     51 
     52TrafficControl Gamestate::trafficControl_;
    5053
    5154Gamestate::Gamestate()
     
    109112
    110113    //if(it->doSelection(id))
    111     dataMap_[mem-data_]=(*it);  // save the mem location of the synchronisable data
     114    if(tempsize!=0)
     115      dataMap_.push_back( obj(it->getObjectID(), it->getCreatorID(), tempsize, mem-data_) );
     116//     dataMap_[mem-data_]=(*it);  // save the mem location of the synchronisable data
    112117    if(!it->getData(mem, id, mode))
    113118      return false; // mem pointer gets automatically increased because of call by reference
     
    148153    if(!s)
    149154    {
    150       Synchronisable::fabricate(mem, mode);
     155      s = Synchronisable::fabricate(mem, mode);
     156      if(s==0)
     157        assert(0);
     158//         COUT(0) << "could not fabricate synchronisable: " << objectheader->objectID << " classid: " << objectheader->classID << " creator: " << objectheader->creatorID << endl;
     159//       else
     160//         COUT(0) << "fabricated: " << objectheader->objectID << " classid: " << objectheader->classID << " creator: "  << objectheader->creatorID << endl;
    151161    }
    152162    else
     
    332342}
    333343
    334 Gamestate* Gamestate::doSelection(unsigned int clientID){
     344Gamestate* Gamestate::doSelection(unsigned int clientID, unsigned int targetSize){
    335345  assert(data_);
    336   std::map<uint32_t, Synchronisable *>::iterator it;
     346  std::list<obj>::iterator it;
    337347
    338348  // allocate memory for new data
     
    341351  Gamestate *gs = new Gamestate(gdata);
    342352  uint8_t *newdata = gdata + sizeof(GamestateHeader);
    343   uint8_t *origdata = GAMESTATE_START(data_);
     353//   uint8_t *origdata = GAMESTATE_START(data_);
    344354
    345355  //copy the GamestateHeader
     
    348358  synchronisableHeader *oldobjectheader, *newobjectheader;
    349359  uint32_t objectOffset;
    350 
     360  unsigned int objectsize, destsize=0;
     361  Synchronisable *object;
     362
     363  //call TrafficControl
     364  trafficControl_.processObjectList( clientID, HEADER->id, &dataMap_ );
     365 
    351366  //copy in the zeros
    352367  for(it=dataMap_.begin(); it!=dataMap_.end(); it++){
    353     oldobjectheader = (synchronisableHeader*)origdata;
     368    oldobjectheader = (synchronisableHeader*)(data_ + (*it).objDataOffset);
    354369    newobjectheader = (synchronisableHeader*)newdata;
    355     uint32_t objectsize = oldobjectheader->size;
    356     assert(it->second->objectID==oldobjectheader->objectID);
     370    object = Synchronisable::getSynchronisable( (*it).objID );
     371    assert(object->objectID == oldobjectheader->objectID);
     372    objectsize = oldobjectheader->size;
    357373    *newobjectheader = *oldobjectheader;
    358374    objectOffset=sizeof(synchronisableHeader); //skip the size and the availableData variables in the objectheader
    359     if(it->second->doSelection(HEADER->id)){
     375    if ( /*object->doSelection(HEADER->id)*/true ){
    360376      assert(newobjectheader->dataAvailable==true);
    361       memcpy(newdata+objectOffset, origdata+objectOffset, objectsize-objectOffset);
     377      memcpy(newdata+objectOffset, data_ + (*it).objDataOffset + objectOffset, objectsize-objectOffset);
    362378    }else{
    363379      newobjectheader->dataAvailable=false;
     
    366382    }
    367383    newdata += objectsize;
    368     origdata += objectsize;
    369   }
     384    destsize += objectsize;
     385//     origdata += objectsize;
     386  }
     387  ((GamestateHeader*)gdata)->datasize = destsize;
     388  assert(destsize!=0);
    370389  return gs;
    371390}
     
    382401
    383402  //preparations
    384   std::map<uint32_t, Synchronisable *>::iterator it;
     403  std::list<obj>::iterator it;
    385404  uint8_t *origdata, *basedata, *destdata, *ndata;
    386405  uint32_t objectOffset, streamOffset=0;    //data offset
     
    388407  synchronisableHeader *origheader;
    389408  synchronisableHeader *destheader;
     409  Synchronisable *object;
    390410
    391411  origdata = GAMESTATE_START(this->data_);
     
    397417  for(it=dataMap_.begin(); it!=dataMap_.end(); it++){
    398418    assert(streamOffset<HEADER->datasize);
    399     bool sendData = it->second->doSelection(HEADER->id);
    400419    origheader = (synchronisableHeader *)(origdata+streamOffset);
    401420    destheader = (synchronisableHeader *)(destdata+streamOffset);
     421    object = Synchronisable::getSynchronisable(origheader->objectID);
     422    bool sendData = object->doSelection(HEADER->id);
    402423
    403424    //copy and partially diff the object header
     
    450471
    451472  //preparations
    452   std::map<uint32_t, Synchronisable *>::iterator it;
     473  std::list<obj>::iterator it;
    453474  uint8_t *origdata, *basedata, *destdata, *ndata;
    454475  uint32_t objectOffset, streamOffset=0;    //data offset
     
    456477  synchronisableHeader *origheader;
    457478  synchronisableHeader *destheader;
     479  Synchronisable *object;
    458480
    459481  origdata = GAMESTATE_START(this->data_);
     
    467489    origheader = (synchronisableHeader *)(origdata+streamOffset);
    468490    destheader = (synchronisableHeader *)(destdata+streamOffset);
     491    object = Synchronisable::getSynchronisable( origheader->objectID );
    469492    bool sendData;
    470493
  • code/branches/network64/src/network/packet/Gamestate.h

    r2309 r2355  
    3131#define NETWORK_PACKETGAMESTATE_H
    3232
    33 #include "../NetworkPrereqs.h"
     33#include "network/NetworkPrereqs.h"
    3434
    3535#include "Packet.h"
    36 #include "network/synchronisable/Synchronisable.h"
     36#include "network/TrafficControl.h"
     37#include "core/CoreIncludes.h"
    3738#include <map>
     39#include <list>
    3840#ifndef NDEBUG
    3941#include "util/CRC32.h"
     
    7981    Gamestate *undiff(Gamestate *base);
    8082    Gamestate* intelligentUnDiff(Gamestate *base);
    81     Gamestate* doSelection(unsigned int clientID);
     83    Gamestate* doSelection(unsigned int clientID, unsigned int targetSize);
    8284    bool compressData();
    8385    bool decompressData();
     
    9294    uint32_t calcGamestateSize(int32_t id, uint8_t mode=0x0);
    9395    void removeObject(ObjectListIterator<Synchronisable> &it);
    94     std::map<uint32_t, Synchronisable*> dataMap_;
     96    std::list<obj> dataMap_;
     97    static TrafficControl trafficControl_;
    9598};
    9699
  • code/branches/network64/src/network/synchronisable/Synchronisable.cc

    r2316 r2355  
    5353namespace orxonox
    5454{
    55 
    5655
    5756  std::map<uint32_t, Synchronisable *> Synchronisable::objectMap_;
  • code/branches/network64/src/network/synchronisable/Synchronisable.h

    r2309 r2355  
    5353namespace orxonox
    5454{
    55   static const uint32_t OBJECTID_UNKNOWN = static_cast<uint32_t>(-1);
    5655
    5756  namespace objectDirection{
     
    9291
    9392    inline uint32_t getObjectID(){return objectID;}
     93    inline unsigned int getCreatorID(){return creatorID;}
    9494    inline uint32_t getClassID(){return classID;}
     95    inline unsigned int getPriority(){ return objectFrequency_;}
     96
    9597  protected:
    9698    Synchronisable(BaseObject* creator);
     
    99101    template <class T> void unregisterVariable(T& var);
    100102    void setObjectMode(uint8_t mode);
    101     void setObjectFrequency(unsigned int freq){ objectFrequency_ = freq; }
     103    void setObjectPriority(unsigned int freq){ objectFrequency_ = freq; }
    102104
    103105
  • code/branches/network64/src/orxonox/objects/worldentities/Model.cc

    r2245 r2355  
    4040    Model::Model(BaseObject* creator) : PositionableEntity(creator)
    4141    {
     42        static unsigned int i=10;
    4243        RegisterObject(Model);
    4344
    4445        this->registerVariables();
     46        this->setObjectPriority(i++);
    4547    }
    4648
Note: See TracChangeset for help on using the changeset viewer.