Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Oct 4, 2015, 9:12:21 PM (9 years ago)
Author:
landauf
Message:

merged branch core7 back to trunk

Location:
code/trunk
Files:
1 deleted
23 edited
6 copied

Legend:

Unmodified
Added
Removed
  • code/trunk

  • code/trunk/src/libraries/network/CMakeLists.txt

    r8858 r10624  
    3434  MasterServerComm.cc
    3535  NetworkFunction.cc
     36  NetworkFunctionIncludes.cc
     37  NetworkFunctionManager.cc
     38  NetworkStaticInitializationHandler.cc
    3639  Host.cc
    3740  Server.cc
     
    4346)
    4447
    45 SET_SOURCE_FILES(NETWORK_HDR_FILES
    46   Client.h
    47   ClientConnection.h
    48   ClientConnectionListener.h
    49   Connection.h
    50   FunctionCall.h
    51   FunctionCallManager.h
    52   #GamestateClient.h
    53   GamestateHandler.h
    54   GamestateManager.h
    55   Host.h
    56   LANDiscoverable.h
    57   LANDiscovery.h
    58   WANDiscoverable.h
    59   WANDiscovery.h
    60   MasterServerComm.h
    61   NetworkChatListener.h
    62   NetworkFunction.h
    63   NetworkPrecompiledHeaders.h
    64   NetworkPrereqs.h
    65   Server.h
    66   MasterServer.h
    67   PeerList.h
    68   ServerList.h
    69   ServerConnection.h
    70   TrafficControl.h
    71 )
    72 
    7348ADD_SUBDIRECTORY(packet)
    7449ADD_SUBDIRECTORY(synchronisable)
    7550
    7651ORXONOX_ADD_LIBRARY(network
     52  FIND_HEADER_FILES
    7753  TOLUA_FILES
    7854    Client.h
     
    9066    core
    9167  SOURCE_FILES
    92     ${NETWORK_SRC_FILES} ${NETWORK_HDR_FILES}
     68    ${NETWORK_SRC_FILES}
    9369)
  • code/trunk/src/libraries/network/Client.cc

    r9667 r10624  
    4545#include "util/Clock.h"
    4646#include "util/Output.h"
    47 #include "util/ScopedSingletonManager.h"
    4847#include "synchronisable/Synchronisable.h"
    4948#include "packet/Chat.h"
     
    5251#include "core/CoreIncludes.h"
    5352#include "core/Game.h"
    54 #include "core/config/CommandLineParser.h"
     53#include "core/commandline/CommandLineParser.h"
     54#include "core/singleton/ScopedSingletonIncludes.h"
    5555
    5656namespace orxonox
    5757{
    5858
    59   ManageScopedSingleton( Client, ScopeID::Root, true );
     59  ManageScopedSingleton( Client, ScopeID::ROOT, false );
    6060
    6161  /**
     
    194194  void Client::connectionClosed()
    195195  {
    196     ObjectList<Synchronisable>::iterator it;
    197     for(it = ObjectList<Synchronisable>::begin(); it; )
    198     {
    199       if( it->getSyncMode() != 0x0 )
    200         (it++)->destroy();
    201       else
    202       {
    203         ++it;
    204       }
    205     }
    206196    Game::getInstance().popState();
    207197    Game::getInstance().popState();
  • code/trunk/src/libraries/network/ClientConnectionListener.cc

    r9667 r10624  
    3535namespace orxonox
    3636{
    37     RegisterAbstractClass(ClientConnectionListener).inheritsFrom(Class(Listable));
     37    RegisterAbstractClass(ClientConnectionListener).inheritsFrom<Listable>();
    3838
    3939    ClientConnectionListener::ClientConnectionListener()
  • code/trunk/src/libraries/network/FunctionCall.cc

    r7503 r10624  
    3232#include "util/MultiType.h"
    3333#include "NetworkFunction.h"
     34#include "NetworkFunctionManager.h"
    3435
    3536namespace orxonox {
     
    4647
    4748bool FunctionCall::execute(){
    48   if( this->bIsStatic_ )
     49  NetworkFunctionBase* fct = NetworkFunctionManager::getInstance().getFunctionByNetworkId( this->functionID_ );
     50  assert( fct != NULL );
     51  assert( this->nrOfArguments_==this->arguments_.size() );
     52  switch(this->nrOfArguments_)
    4953  {
    50     NetworkFunctionStatic *fct = NetworkFunctionStatic::getFunction( this->functionID_ );
    51     assert( this->nrOfArguments_==this->arguments_.size() );
    52     switch(this->nrOfArguments_)
    53     {
    54       case 0:
    55         fct->call();
    56         break;
    57       case 1:
    58         fct->call(this->arguments_[0]);
    59         break;
    60       case 2:
    61         fct->call(this->arguments_[0], this->arguments_[1]);
    62         break;
    63       case 3:
    64         fct->call(this->arguments_[0], this->arguments_[1], this->arguments_[2]);
    65         break;
    66       case 4:
    67         fct->call(this->arguments_[0], this->arguments_[1], this->arguments_[2], this->arguments_[3]);
    68         break;
    69       case 5:
    70         fct->call(this->arguments_[0], this->arguments_[1], this->arguments_[2], this->arguments_[3], this->arguments_[4]);
    71         break;
    72       default:
    73         assert(0);
    74     }
     54    case 0:
     55      return fct->call(this->objectID_);
     56    case 1:
     57      return fct->call(this->objectID_, this->arguments_[0]);
     58    case 2:
     59      return fct->call(this->objectID_, this->arguments_[0], this->arguments_[1]);
     60    case 3:
     61      return fct->call(this->objectID_, this->arguments_[0], this->arguments_[1], this->arguments_[2]);
     62    case 4:
     63      return fct->call(this->objectID_, this->arguments_[0], this->arguments_[1], this->arguments_[2], this->arguments_[3]);
     64    case 5:
     65      return fct->call(this->objectID_, this->arguments_[0], this->arguments_[1], this->arguments_[2], this->arguments_[3], this->arguments_[4]);
     66    default:
     67      assert(0);
     68      return true; // return true to avoid that this functions gets called over and over again
    7569  }
    76   else // not a static function, so also handle with the objectID
    77   {
    78     NetworkMemberFunctionBase *fct = NetworkMemberFunctionBase::getFunction( this->functionID_ );
    79     switch(this->nrOfArguments_)
    80     {
    81       case 0:
    82         if( !fct->call(this->objectID_) )
    83           return false;
    84         break;
    85       case 1:
    86         if( !fct->call(this->objectID_, this->arguments_[0]) )
    87           return false;
    88         break;
    89       case 2:
    90         if( !fct->call(this->objectID_, this->arguments_[0], this->arguments_[1]) )
    91           return false;
    92         break;
    93       case 3:
    94         if( !fct->call(this->objectID_, this->arguments_[0], this->arguments_[1], this->arguments_[2]) )
    95           return false;
    96         break;
    97       case 4:
    98         if( !fct->call(this->objectID_, this->arguments_[0], this->arguments_[1], this->arguments_[2], this->arguments_[3]) )
    99           return false;
    100         break;
    101       case 5:
    102         if( !fct->call(this->objectID_, this->arguments_[0], this->arguments_[1], this->arguments_[2], this->arguments_[3], this->arguments_[4]) )
    103           return false;
    104         break;
    105       default:
    106         assert(0);
    107     }
    108   }
    109   return true;
    11070}
    11171
    112 void FunctionCall::setCallStatic( uint32_t networkID, const MultiType* mt1, const MultiType* mt2, const MultiType* mt3, const MultiType* mt4, const MultiType* mt5){
     72void FunctionCall::setCall( uint32_t networkID, uint32_t objectID, const MultiType& mt1, const MultiType& mt2, const MultiType& mt3, const MultiType& mt4, const MultiType& mt5){
    11373
    11474  // first determine the size that has to be reserved for this call
    115   uint32_t callsize = 2*sizeof(uint32_t)+sizeof(uint8_t); //size for network-function-id and nrOfArguments and for bool isStatic
     75  uint32_t callsize = 3*sizeof(uint32_t); //size for network-function-id and nrOfArguments and the objectID
    11676  uint32_t nrOfArguments = 0;
    117   if(mt1)
     77  if(!mt1.null())
    11878  {
    11979    nrOfArguments++;
    120     callsize += mt1->getNetworkSize();
    121     this->arguments_.push_back(*mt1);
    122     if(mt2)
     80    callsize += mt1.getNetworkSize();
     81    this->arguments_.push_back(mt1);
     82    if(!mt2.null())
    12383    {
    12484      nrOfArguments++;
    125       callsize += mt2->getNetworkSize();
    126       this->arguments_.push_back(*mt2);
    127       if(mt3)
     85      callsize += mt2.getNetworkSize();
     86      this->arguments_.push_back(mt2);
     87      if(!mt3.null())
    12888      {
    12989        nrOfArguments++;
    130         callsize += mt3->getNetworkSize();
    131         this->arguments_.push_back(*mt3);
    132         if(mt4)
     90        callsize += mt3.getNetworkSize();
     91        this->arguments_.push_back(mt3);
     92        if(!mt4.null())
    13393        {
    13494          nrOfArguments++;
    135           callsize += mt4->getNetworkSize();
    136           this->arguments_.push_back(*mt4);
    137           if(mt5)
     95          callsize += mt4.getNetworkSize();
     96          this->arguments_.push_back(mt4);
     97          if(!mt5.null())
    13898          {
    13999            nrOfArguments++;
    140             callsize += mt5->getNetworkSize();
    141             this->arguments_.push_back(*mt5);
     100            callsize += mt5.getNetworkSize();
     101            this->arguments_.push_back(mt5);
    142102          }
    143103        }
     
    146106  }
    147107  this->nrOfArguments_ = nrOfArguments;
     108  this->functionID_ = networkID;
     109  this->objectID_ = objectID;
    148110  this->size_ = callsize;
    149   this->bIsStatic_ = true;
    150   this->functionID_ = networkID;
    151 }
    152 
    153 void FunctionCall::setCallMember( uint32_t networkID, uint32_t objectID, const MultiType* mt1, const MultiType* mt2, const MultiType* mt3, const MultiType* mt4, const MultiType* mt5){
    154 
    155   // first determine the size that has to be reserved for this call
    156   uint32_t callsize = 3*sizeof(uint32_t)+sizeof(uint8_t); //size for network-function-id and nrOfArguments and the objectID and bIsStatic
    157   uint32_t nrOfArguments = 0;
    158   if(mt1)
    159   {
    160     nrOfArguments++;
    161     callsize += mt1->getNetworkSize();
    162     this->arguments_.push_back(*mt1);
    163     if(mt2)
    164     {
    165       nrOfArguments++;
    166       callsize += mt2->getNetworkSize();
    167       this->arguments_.push_back(*mt2);
    168       if(mt3)
    169       {
    170         nrOfArguments++;
    171         callsize += mt3->getNetworkSize();
    172         this->arguments_.push_back(*mt3);
    173         if(mt4)
    174         {
    175           nrOfArguments++;
    176           callsize += mt4->getNetworkSize();
    177           this->arguments_.push_back(*mt4);
    178           if(mt5)
    179           {
    180             nrOfArguments++;
    181             callsize += mt5->getNetworkSize();
    182             this->arguments_.push_back(*mt5);
    183           }
    184         }
    185       }
    186     }
    187   }
    188   this->nrOfArguments_ = nrOfArguments;
    189   this->bIsStatic_ = false;
    190   this->functionID_ = networkID;
    191   this->size_ = callsize;
    192   this->objectID_ = objectID;
    193111}
    194112
     
    196114{
    197115  this->functionID_ = *(uint32_t*)mem;
    198   this->bIsStatic_ = *(uint8_t*)(mem+sizeof(uint32_t));
    199   this->nrOfArguments_ = *(uint32_t*)(mem+sizeof(uint32_t)+sizeof(uint8_t));
    200   if( this->bIsStatic_ )
    201   {
    202     mem += 2*sizeof(uint32_t)+sizeof(uint8_t);
    203   }
    204   else
    205   {
    206     this->objectID_ = *(uint32_t*)(mem+2*sizeof(uint32_t)+sizeof(uint8_t));
    207     mem += 3*sizeof(uint32_t)+sizeof(uint8_t);
    208   }
     116  this->nrOfArguments_ = *(uint32_t*)(mem+sizeof(uint32_t));
     117  this->objectID_ = *(uint32_t*)(mem+2*sizeof(uint32_t));
     118  mem += 3*sizeof(uint32_t);
    209119  for( unsigned int i=0; i<this->nrOfArguments_; ++i )
    210120  {
     
    218128  // now serialise the mt values and copy the function id and isStatic
    219129  *(uint32_t*)mem = this->functionID_;
    220   *(uint8_t*)(mem+sizeof(uint32_t)) = this->bIsStatic_;
    221   *(uint32_t*)(mem+sizeof(uint32_t)+sizeof(uint8_t)) = this->nrOfArguments_;
    222   if( this->bIsStatic_ )
    223   {
    224     mem += 2*sizeof(uint32_t)+sizeof(uint8_t);
    225   }
    226   else
    227   {
    228     *(uint32_t*)(mem+2*sizeof(uint32_t)+sizeof(uint8_t)) = this->objectID_;
    229     mem += 3*sizeof(uint32_t)+sizeof(uint8_t);
    230   }
     130  *(uint32_t*)(mem+sizeof(uint32_t)) = this->nrOfArguments_;
     131  *(uint32_t*)(mem+2*sizeof(uint32_t)) = this->objectID_;
     132  mem += 3*sizeof(uint32_t);
    231133  for( std::vector<MultiType>::iterator it = this->arguments_.begin(); it!=this->arguments_.end(); ++it )
    232134  {
  • code/trunk/src/libraries/network/FunctionCall.h

    r7495 r10624  
    5252  bool execute();
    5353
    54   void setCallStatic( uint32_t networkID, const MultiType* mt1=0, const MultiType* mt2=0, const MultiType* mt3=0, const MultiType* mt4=0, const MultiType* mt5=0);
    55   void setCallMember( uint32_t networkID, uint32_t objectID, const MultiType* mt1=0, const MultiType* mt2=0, const MultiType* mt3=0, const MultiType* mt4=0, const MultiType* mt5=0);
     54  void setCall( uint32_t networkID, uint32_t objectID, const MultiType& mt1, const MultiType& mt2, const MultiType& mt3, const MultiType& mt4, const MultiType& mt5);
    5655 
    5756  void saveData( uint8_t*& mem );
     
    5958private:
    6059  uint32_t                  nrOfArguments_;
    61   bool                      bIsStatic_;
    6260  uint32_t                  functionID_;
    63   uint32_t                  objectID_;
     61  uint32_t                  objectID_; // equals OBJECTID_UNKNOWN for static functions
    6462  uint32_t                  size_;
    6563  std::vector<MultiType>    arguments_;
  • code/trunk/src/libraries/network/FunctionCallManager.cc

    r8403 r10624  
    3939std::vector<std::pair<FunctionCall, std::pair<uint32_t, uint32_t> > > FunctionCallManager::sIncomingFunctionCallBuffer_;
    4040
    41 // Static calls
    4241
    43 void FunctionCallManager::addCallStatic(uint32_t functionID, uint32_t peerID)
     42void FunctionCallManager::addCall(uint32_t functionID, uint32_t objectID, uint32_t peerID, const MultiType& mt1, const MultiType& mt2, const MultiType& mt3, const MultiType& mt4, const MultiType& mt5)
    4443{
    4544  if(sPeerMap_.find(peerID)==sPeerMap_.end())
     
    4847    FunctionCallManager::sPeerMap_[peerID]->setPeerID(peerID);
    4948  }
    50   FunctionCallManager::sPeerMap_[peerID]->addCallStatic(functionID);
    51 }
    52 void FunctionCallManager::addCallStatic(uint32_t functionID, uint32_t peerID, const MultiType& mt1)
    53 {
    54   if(sPeerMap_.find(peerID)==sPeerMap_.end())
    55   {
    56     FunctionCallManager::sPeerMap_[peerID] = new packet::FunctionCalls;
    57     FunctionCallManager::sPeerMap_[peerID]->setPeerID(peerID);
    58   }
    59   FunctionCallManager:: sPeerMap_[peerID]->addCallStatic(functionID, &mt1);
    60 }
    61 void FunctionCallManager::addCallStatic(uint32_t functionID, uint32_t peerID, const MultiType& mt1, const MultiType& mt2)
    62 {
    63   if(sPeerMap_.find(peerID)==sPeerMap_.end())
    64   {
    65     FunctionCallManager::sPeerMap_[peerID] = new packet::FunctionCalls;
    66     FunctionCallManager::sPeerMap_[peerID]->setPeerID(peerID);
    67   }
    68   FunctionCallManager:: sPeerMap_[peerID]->addCallStatic(functionID, &mt1, &mt2);
    69 }
    70 void FunctionCallManager::addCallStatic(uint32_t functionID, uint32_t peerID, const MultiType& mt1, const MultiType& mt2, const MultiType& mt3)
    71 {
    72   if(sPeerMap_.find(peerID)==sPeerMap_.end())
    73   {
    74     FunctionCallManager::sPeerMap_[peerID] = new packet::FunctionCalls;
    75     FunctionCallManager::sPeerMap_[peerID]->setPeerID(peerID);
    76   }
    77   FunctionCallManager:: sPeerMap_[peerID]->addCallStatic(functionID, &mt1, &mt2, &mt3);
    78 }
    79 void FunctionCallManager::addCallStatic(uint32_t functionID, uint32_t peerID, const MultiType& mt1, const MultiType& mt2, const MultiType& mt3, const MultiType& mt4)
    80 {
    81   if(sPeerMap_.find(peerID)==sPeerMap_.end())
    82   {
    83     FunctionCallManager::sPeerMap_[peerID] = new packet::FunctionCalls;
    84     FunctionCallManager::sPeerMap_[peerID]->setPeerID(peerID);
    85   }
    86   FunctionCallManager:: sPeerMap_[peerID]->addCallStatic(functionID, &mt1, &mt2, &mt3, &mt4);
    87 }
    88 void FunctionCallManager::addCallStatic(uint32_t functionID, uint32_t peerID, const MultiType& mt1, const MultiType& mt2, const MultiType& mt3, const MultiType& mt4, const MultiType& mt5)
    89 {
    90   if(sPeerMap_.find(peerID)==sPeerMap_.end())
    91   {
    92     FunctionCallManager::sPeerMap_[peerID] = new packet::FunctionCalls;
    93     FunctionCallManager::sPeerMap_[peerID]->setPeerID(peerID);
    94   }
    95   FunctionCallManager:: sPeerMap_[peerID]->addCallStatic(functionID, &mt1, &mt2, &mt3, &mt4, &mt5);
    96 }
    97 
    98 
    99 // MemberCalls
    100 
    101 void FunctionCallManager::addCallMember(uint32_t functionID, uint32_t objectID, uint32_t peerID)
    102 {
    103   if(sPeerMap_.find(peerID)==sPeerMap_.end())
    104   {
    105     FunctionCallManager::sPeerMap_[peerID] = new packet::FunctionCalls;
    106     FunctionCallManager::sPeerMap_[peerID]->setPeerID(peerID);
    107   }
    108   FunctionCallManager::sPeerMap_[peerID]->addCallMember(functionID, objectID);
    109 }
    110 void FunctionCallManager::addCallMember(uint32_t functionID, uint32_t objectID, uint32_t peerID, const MultiType& mt1)
    111 {
    112   if(sPeerMap_.find(peerID)==sPeerMap_.end())
    113   {
    114     FunctionCallManager::sPeerMap_[peerID] = new packet::FunctionCalls;
    115     FunctionCallManager::sPeerMap_[peerID]->setPeerID(peerID);
    116   }
    117   FunctionCallManager::sPeerMap_[peerID]->addCallMember(functionID, objectID, &mt1);
    118 }
    119 void FunctionCallManager::addCallMember(uint32_t functionID, uint32_t objectID, uint32_t peerID, const MultiType& mt1, const MultiType& mt2)
    120 {
    121   if(sPeerMap_.find(peerID)==sPeerMap_.end())
    122   {
    123     FunctionCallManager::sPeerMap_[peerID] = new packet::FunctionCalls;
    124     FunctionCallManager::sPeerMap_[peerID]->setPeerID(peerID);
    125   }
    126   FunctionCallManager::sPeerMap_[peerID]->addCallMember(functionID, objectID, &mt1, &mt2);
    127 }
    128 void FunctionCallManager::addCallMember(uint32_t functionID, uint32_t objectID, uint32_t peerID, const MultiType& mt1, const MultiType& mt2, const MultiType& mt3)
    129 {
    130   if(sPeerMap_.find(peerID)==sPeerMap_.end())
    131   {
    132     FunctionCallManager::sPeerMap_[peerID] = new packet::FunctionCalls;
    133     FunctionCallManager::sPeerMap_[peerID]->setPeerID(peerID);
    134   }
    135   FunctionCallManager::sPeerMap_[peerID]->addCallMember(functionID, objectID, &mt1, &mt2, &mt3);
    136 }
    137 void FunctionCallManager::addCallMember(uint32_t functionID, uint32_t objectID, uint32_t peerID, const MultiType& mt1, const MultiType& mt2, const MultiType& mt3, const MultiType& mt4)
    138 {
    139   if(sPeerMap_.find(peerID)==sPeerMap_.end())
    140   {
    141     FunctionCallManager::sPeerMap_[peerID] = new packet::FunctionCalls;
    142     FunctionCallManager::sPeerMap_[peerID]->setPeerID(peerID);
    143   }
    144   FunctionCallManager::sPeerMap_[peerID]->addCallMember(functionID, objectID, &mt1, &mt2, &mt3, &mt4);
    145 }
    146 void FunctionCallManager::addCallMember(uint32_t functionID, uint32_t objectID, uint32_t peerID, const MultiType& mt1, const MultiType& mt2, const MultiType& mt3, const MultiType& mt4, const MultiType& mt5)
    147 {
    148   if(sPeerMap_.find(peerID)==sPeerMap_.end())
    149   {
    150     FunctionCallManager::sPeerMap_[peerID] = new packet::FunctionCalls;
    151     FunctionCallManager::sPeerMap_[peerID]->setPeerID(peerID);
    152   }
    153   FunctionCallManager::sPeerMap_[peerID]->addCallMember(functionID, objectID, &mt1, &mt2, &mt3, &mt4, &mt5);
     49  FunctionCallManager::sPeerMap_[peerID]->addCall(functionID, objectID, mt1, mt2, mt3, mt4, mt5);
    15450}
    15551
  • code/trunk/src/libraries/network/FunctionCallManager.h

    r7801 r10624  
    4646{
    4747public:
    48   static void addCallStatic(uint32_t functionID, uint32_t peerID);
    49   static void addCallStatic(uint32_t functionID, uint32_t peerID, const MultiType& mt1);
    50   static void addCallStatic(uint32_t functionID, uint32_t peerID, const MultiType& mt1, const MultiType& mt2);
    51   static void addCallStatic(uint32_t functionID, uint32_t peerID, const MultiType& mt1, const MultiType& mt2, const MultiType& mt3);
    52   static void addCallStatic(uint32_t functionID, uint32_t peerID, const MultiType& mt1, const MultiType& mt2, const MultiType& mt3, const MultiType& mt4);
    53   static void addCallStatic(uint32_t functionID, uint32_t peerID, const MultiType& mt1, const MultiType& mt2, const MultiType& mt3, const MultiType& mt4, const MultiType& mt5);
    54 
    55   static void addCallMember(uint32_t functionID, uint32_t objectID, uint32_t peerID);
    56   static void addCallMember(uint32_t functionID, uint32_t objectID, uint32_t peerID, const MultiType& mt1);
    57   static void addCallMember(uint32_t functionID, uint32_t objectID, uint32_t peerID, const MultiType& mt1, const MultiType& mt2);
    58   static void addCallMember(uint32_t functionID, uint32_t objectID, uint32_t peerID, const MultiType& mt1, const MultiType& mt2, const MultiType& mt3);
    59   static void addCallMember(uint32_t functionID, uint32_t objectID, uint32_t peerID, const MultiType& mt1, const MultiType& mt2, const MultiType& mt3, const MultiType& mt4);
    60   static void addCallMember(uint32_t functionID, uint32_t objectID, uint32_t peerID, const MultiType& mt1, const MultiType& mt2, const MultiType& mt3, const MultiType& mt4, const MultiType& mt5);
     48  static void addCall(uint32_t functionID, uint32_t objectID, uint32_t peerID, const MultiType& mt1, const MultiType& mt2, const MultiType& mt3, const MultiType& mt4, const MultiType& mt5);
    6149
    6250  static void sendCalls(orxonox::Host* host);
  • code/trunk/src/libraries/network/Host.cc

    r9667 r10624  
    3434#include "core/CoreIncludes.h"
    3535#include "core/object/ObjectList.h"
    36 #include "core/command/ConsoleCommand.h"
     36#include "core/command/ConsoleCommandIncludes.h"
    3737#include "NetworkChatListener.h"
    3838
     
    143143  //////////////////////////////////////////////////////////////////////////
    144144
     145  RegisterAbstractClass(NetworkChatListener).inheritsFrom<Listable>();
     146
    145147  NetworkChatListener::NetworkChatListener()
    146148  {
  • code/trunk/src/libraries/network/LANDiscovery.cc

    r10622 r10624  
    3232#include <cstring>
    3333
    34 #include "util/ScopedSingletonManager.h"
    3534#include "core/CoreIncludes.h"
     35#include "core/singleton/ScopedSingletonIncludes.h"
    3636
    3737
    3838namespace orxonox
    3939{
    40   ManageScopedSingleton(LANDiscovery, ScopeID::Graphics, true);
     40  ManageScopedSingleton(LANDiscovery, ScopeID::GRAPHICS, false);
    4141
    4242  LANDiscovery::LANDiscovery()
  • code/trunk/src/libraries/network/MasterServer.cc

    r10622 r10624  
    2828
    2929#include "MasterServer.h"
    30 #include "util/ScopedSingletonManager.h"
    31 #include "core/command/ConsoleCommand.h"
     30#include "core/command/ConsoleCommandIncludes.h"
    3231#include "core/CoreIncludes.h"
    3332#include "core/CorePrereqs.h"
     33#include "core/singleton/ScopedSingletonIncludes.h"
    3434#include "util/Output.h"
    3535
  • code/trunk/src/libraries/network/NetworkFunction.cc

    r9667 r10624  
    2828
    2929#include "NetworkFunction.h"
    30 #include "core/CoreIncludes.h"
     30#include "NetworkFunctionManager.h"
    3131
    3232namespace orxonox
    3333{
    34   std::map<uint32_t, bool> NetworkFunctionBase::isStaticMap_;
     34    NetworkFunctionBase::NetworkFunctionBase(const std::string& name, const NetworkFunctionPointer& pointer)
     35    {
     36        static uint32_t networkID = 0;
     37        this->networkID_ = networkID++;
     38        this->name_ = name;
     39        this->pointer_ = pointer;
     40    }
    3541
    36   std::map<NetworkFunctionPointer, NetworkMemberFunctionBase*> NetworkMemberFunctionBase::functorMap_;
    37   std::map<uint32_t, NetworkMemberFunctionBase*> NetworkMemberFunctionBase::idMap_;
    38 
    39   // no suitable factory for NetworkFunctionBase (and children), so we declare it abstract
    40   RegisterAbstractClass(NetworkFunctionBase).inheritsFrom(Class(Listable));
    41   RegisterAbstractClass(NetworkFunctionStatic).inheritsFrom(Class(NetworkFunctionBase));
    42   RegisterAbstractClass(NetworkMemberFunctionBase).inheritsFrom(Class(NetworkFunctionBase));
    43 
    44   NetworkFunctionBase::NetworkFunctionBase(const std::string& name)
    45   {
    46       RegisterObject(NetworkFunctionBase);
    47 
    48     static uint32_t networkID = 0;
    49     this->networkID_ = networkID++;
    50 
    51     this->name_ = name;
    52     NetworkFunctionBase::getNameMap()[name] = this;
    53   }
    54   NetworkFunctionBase::~NetworkFunctionBase()
    55   {
    56   }
    57 
    58 
    59   void NetworkFunctionBase::destroyAllNetworkFunctions()
    60   {
    61     std::map<std::string, NetworkFunctionBase*>& map = NetworkFunctionBase::getNameMap();
    62     std::map<std::string, NetworkFunctionBase*>::iterator it;
    63     for( it=map.begin(); it!=map.end(); ++it )
    64       delete it->second;
    65   }
    66 
    67 
    68   /*static*/ std::map<std::string, NetworkFunctionBase*>& NetworkFunctionBase::getNameMap()
    69   {
    70     static std::map<std::string, NetworkFunctionBase*> nameMap_;
    71     return nameMap_;
    72   }
    73 
    74 
    75   NetworkFunctionStatic::NetworkFunctionStatic(const FunctorStaticPtr& functor, const std::string& name, const NetworkFunctionPointer& p):
    76     NetworkFunctionBase(name)
    77   {
    78     RegisterObject(NetworkFunctionStatic);
    79 
    80     this->functor_ = functor;
    81     NetworkFunctionStatic::getFunctorMap()[p] = this;
    82     NetworkFunctionStatic::getIdMap()[ this->getNetworkID() ] = this;
    83   }
    84 
    85   /*static*/ std::map<NetworkFunctionPointer, NetworkFunctionStatic*>& NetworkFunctionStatic::getFunctorMap()
    86   {
    87     static std::map<NetworkFunctionPointer, NetworkFunctionStatic*> functorMap_;
    88     return functorMap_;
    89   }
    90 
    91   /*static*/ std::map<uint32_t, NetworkFunctionStatic*>& NetworkFunctionStatic::getIdMap()
    92   {
    93     static std::map<uint32_t, NetworkFunctionStatic*> idMap_;
    94     return idMap_;
    95   }
    96 
    97 
    98   NetworkMemberFunctionBase::NetworkMemberFunctionBase(const std::string& name, const NetworkFunctionPointer& p):
    99     NetworkFunctionBase(name)
    100   {
    101     RegisterObject(NetworkMemberFunctionBase);
    102 
    103     this->functorMap_[p] = this;
    104     this->idMap_[ this->getNetworkID() ] = this;
    105   }
    106 
    107   NetworkMemberFunctionBase::~NetworkMemberFunctionBase()
    108   {
    109   }
    110 
    111 
     42    void NetworkFunctionBase::setNetworkID(uint32_t id)
     43    {
     44        this->networkID_ = id;
     45        NetworkFunctionManager::getInstance().registerFunction(this);   // register with new id
     46    }
    11247}
  • code/trunk/src/libraries/network/NetworkFunction.h

    r9667 r10624  
    3636#include <map>
    3737#include <string>
    38 #include <boost/preprocessor/cat.hpp>
    39 #include <boost/static_assert.hpp>
    40 
    41 #include "core/object/Listable.h"
    42 #include "core/class/Identifier.h"
     38
    4339#include "core/command/Functor.h"
    4440#include "FunctionCallManager.h"
     
    6056  {
    6157#if defined(ORXONOX_COMPILER_GCC) && defined(ORXONOX_ARCH_32)
    62     return pointer[0]<b.pointer[0] ? true : pointer[1]<b.pointer[1];
    63 #else //ORXONOX_COMPILER_GCC
    64     return pointer[0]<b.pointer[0] ? true : ( pointer[1]<b.pointer[1] ? true : ( pointer[2]<b.pointer[2] ? true : pointer[3]<b.pointer[3] ) );
    65 #endif //ORXONOX_COMPILER_GCC
     58    if (pointer[0] != b.pointer[0])
     59        return pointer[0] < b.pointer[0];
     60    else if (pointer[1] != b.pointer[1])
     61        return pointer[1] < b.pointer[1];
     62    else
     63        return false;
     64#else
     65    if (pointer[0] != b.pointer[0])
     66        return pointer[0] < b.pointer[0];
     67    else if (pointer[1] != b.pointer[1])
     68        return pointer[1] < b.pointer[1];
     69    else if (pointer[2] != b.pointer[2])
     70        return pointer[2] < b.pointer[2];
     71    else if (pointer[3] != b.pointer[3])
     72        return pointer[3] < b.pointer[3];
     73    else
     74        return false;
     75#endif
    6676  }
    6777};
     
    7181
    7282
    73 class _NetworkExport NetworkFunctionBase: virtual public Listable {
    74   public:
    75     NetworkFunctionBase(const std::string& name);
    76     ~NetworkFunctionBase();
    77 
    78     virtual void        setNetworkID(uint32_t id)       { this->networkID_ = id; }
    79     inline uint32_t     getNetworkID() const            { return this->networkID_; }
    80     inline const std::string& getName() const           { return name_; }
    81     static inline bool  isStatic( uint32_t networkID )  { return isStaticMap_[networkID]; }
    82 
    83     static inline void setNetworkID(const std::string& name, uint32_t id)
    84     {
    85         std::map<std::string, NetworkFunctionBase*>& map = NetworkFunctionBase::getNameMap();
    86         assert( map.find(name)!=map.end() );
    87         map[name]->setNetworkID(id);
    88     }
    89 
    90     static void destroyAllNetworkFunctions();
    91 
    92   protected:
    93     static std::map<uint32_t, bool> isStaticMap_;
    94 
    95   private:
    96     static std::map<std::string, NetworkFunctionBase*>& getNameMap();
    97     uint32_t networkID_;
    98     std::string name_;
    99 
    100 };
    101 
    102 
    103 class _NetworkExport NetworkFunctionStatic: public NetworkFunctionBase {
    104   public:
    105     NetworkFunctionStatic(const FunctorStaticPtr& functor, const std::string& name, const NetworkFunctionPointer& p);
    106 
    107     inline void call(){ (*this->functor_)(); }
    108     inline void call(const MultiType& mt1){ (*this->functor_)(mt1); }
    109     inline void call(const MultiType& mt1, const MultiType& mt2){ (*this->functor_)(mt1, mt2); }
    110     inline void call(const MultiType& mt1, const MultiType& mt2, const MultiType& mt3){ (*this->functor_)(mt1, mt2, mt3); }
    111     inline void call(const MultiType& mt1, const MultiType& mt2, const MultiType& mt3, const MultiType& mt4){ (*this->functor_)(mt1, mt2, mt3, mt4); }
    112     inline void call(const MultiType& mt1, const MultiType& mt2, const MultiType& mt3, const MultiType& mt4, const MultiType& mt5){ (*this->functor_)(mt1, mt2, mt3, mt4, mt5); }
    113 
    114     virtual void setNetworkID( uint32_t id )
    115         { NetworkFunctionBase::setNetworkID( id ); NetworkFunctionStatic::getIdMap()[id] = this; }
    116     static inline NetworkFunctionStatic* getNetworkFunction( uint32_t id)
    117         { assert( NetworkFunctionStatic::getIdMap().find(id)!=NetworkFunctionStatic::getIdMap().end() ); return NetworkFunctionStatic::getIdMap()[id]; }
    118     static NetworkFunctionStatic* getFunction( uint32_t id )
    119         { assert( NetworkFunctionStatic::getIdMap().find(id) != NetworkFunctionStatic::getIdMap().end() ); return NetworkFunctionStatic::getIdMap()[id]; }
    120     static NetworkFunctionStatic* getFunction( const NetworkFunctionPointer& p )
    121         { assert( NetworkFunctionStatic::getFunctorMap().find(p) != NetworkFunctionStatic::getFunctorMap().end() ); return NetworkFunctionStatic::getFunctorMap()[p]; }
    122 
    123   private:
    124     static std::map<NetworkFunctionPointer, NetworkFunctionStatic*>& getFunctorMap();
    125     static std::map<uint32_t, NetworkFunctionStatic*>& getIdMap();
    126     FunctorStaticPtr functor_;
    127 
    128 };
    129 
    130 
    131 class _NetworkExport NetworkMemberFunctionBase: public NetworkFunctionBase {
    132   public:
    133     NetworkMemberFunctionBase(const std::string& name, const NetworkFunctionPointer& p);
    134     ~NetworkMemberFunctionBase();
    135 
    136     virtual void setNetworkID( uint32_t id ){ NetworkFunctionBase::setNetworkID( id ); idMap_[id] = this; }
    137     static inline NetworkMemberFunctionBase* getNetworkFunction( uint32_t id){ assert( idMap_.find(id)!=idMap_.end() ); return idMap_[id]; }
    138     static NetworkMemberFunctionBase* getFunction( uint32_t id ){ assert( idMap_.find(id) != idMap_.end() ); return idMap_[id]; }
    139     static NetworkMemberFunctionBase* getFunction( const NetworkFunctionPointer& p ){ assert( functorMap_.find(p) != functorMap_.end() ); return functorMap_[p]; }
    140 
    141     //
     83class _NetworkExport NetworkFunctionBase {
     84  public:
     85    NetworkFunctionBase(const std::string& name, const NetworkFunctionPointer& pointer);
     86    virtual ~NetworkFunctionBase() {}
     87
     88    void setNetworkID(uint32_t id);
     89    inline uint32_t     getNetworkID() const                { return this->networkID_; }
     90    inline const std::string& getName() const               { return this->name_; }
     91    inline const NetworkFunctionPointer& getPointer() const { return this->pointer_; }
     92
    14293    virtual bool call(uint32_t objectID)=0;
    14394    virtual bool call(uint32_t objectID, const MultiType& mt1)=0;
     
    14899
    149100  private:
    150     static std::map<NetworkFunctionPointer, NetworkMemberFunctionBase*> functorMap_;
    151     static std::map<uint32_t, NetworkMemberFunctionBase*> idMap_;
     101    uint32_t networkID_;
     102    std::string name_;
     103    NetworkFunctionPointer pointer_;
     104
     105};
     106
     107
     108class _NetworkExport NetworkFunctionStatic: public NetworkFunctionBase {
     109  public:
     110    NetworkFunctionStatic(const FunctorStaticPtr& functor, const std::string& name, const NetworkFunctionPointer& p)
     111        : NetworkFunctionBase(name, p)
     112        , functor_(functor)
     113    { }
     114
     115    // ignore the objectID because its a static function
     116    virtual bool call(uint32_t objectID){ (*this->functor_)(); return true; }
     117    virtual bool call(uint32_t objectID, const MultiType& mt1){ (*this->functor_)(mt1); return true; }
     118    virtual bool call(uint32_t objectID, const MultiType& mt1, const MultiType& mt2){ (*this->functor_)(mt1, mt2); return true; }
     119    virtual bool call(uint32_t objectID, const MultiType& mt1, const MultiType& mt2, const MultiType& mt3){ (*this->functor_)(mt1, mt2, mt3); return true; }
     120    virtual bool call(uint32_t objectID, const MultiType& mt1, const MultiType& mt2, const MultiType& mt3, const MultiType& mt4){ (*this->functor_)(mt1, mt2, mt3, mt4); return true; }
     121    virtual bool call(uint32_t objectID, const MultiType& mt1, const MultiType& mt2, const MultiType& mt3, const MultiType& mt4, const MultiType& mt5){ (*this->functor_)(mt1, mt2, mt3, mt4, mt5); return true; }
     122
     123  private:
     124    FunctorStaticPtr functor_;
     125
     126};
     127
     128
     129class _NetworkExport NetworkMemberFunctionBase: public NetworkFunctionBase {
     130  public:
     131    NetworkMemberFunctionBase(const std::string& name, const NetworkFunctionPointer& p)
     132        : NetworkFunctionBase(name, p)
     133    { }
    152134};
    153135
     
    155137template <class T> class NetworkMemberFunction: public NetworkMemberFunctionBase {
    156138  public:
    157     NetworkMemberFunction(const FunctorMemberPtr<T>& functor, const std::string& name, const NetworkFunctionPointer& p);
     139    NetworkMemberFunction(const FunctorMemberPtr<T>& functor, const std::string& name, const NetworkFunctionPointer& p)
     140        : NetworkMemberFunctionBase(name, p)
     141        , functor_(functor)
     142    { }
    158143
    159144    inline bool call(uint32_t objectID)
     
    222207};
    223208
    224 template <class T> NetworkMemberFunction<T>::NetworkMemberFunction(const FunctorMemberPtr<T>& functor, const std::string& name, const NetworkFunctionPointer& p):
    225     NetworkMemberFunctionBase(name, p), functor_(functor)
    226 {
    227209}
    228210
    229 template<class T> inline void copyPtr( T ptr, NetworkFunctionPointer& destptr)
    230 {
    231   if( sizeof(NetworkFunctionPointer)-sizeof(T) > 0)
    232     memset((uint8_t*)&destptr + sizeof(T), 0, sizeof(NetworkFunctionPointer)-sizeof(T));
    233   T p2 = ptr;
    234   memcpy( &destptr, &p2, sizeof(T) );
    235 //   for(unsigned int i=0; i<(sizeof(T)-1/4)+1; i++)
    236 //     *((uint32_t*)destptr+i) = p2>>32*i;
    237 }
    238 
    239 template<class T> inline void* registerStaticNetworkFunctionFct( T ptr, const std::string& name )
    240 {
    241   BOOST_STATIC_ASSERT( sizeof(T)<=sizeof(NetworkFunctionPointer) ); // if this fails your compiler uses bigger pointers for static functions than defined above
    242   NetworkFunctionPointer destptr;
    243   copyPtr( ptr, destptr );
    244   new NetworkFunctionStatic( createFunctor(ptr), name, destptr );
    245   return 0;
    246 }
    247 
    248 template<class T, class PT> inline void* registerMemberNetworkFunctionFct( PT ptr, const std::string& name )
    249 {
    250   BOOST_STATIC_ASSERT( sizeof(PT)<=sizeof(NetworkFunctionPointer) ); // if this fails your compiler uses bigger pointers for a specific kind of member functions than defined above
    251   NetworkFunctionPointer destptr;
    252   copyPtr( ptr, destptr );
    253   new NetworkMemberFunction<T>( createFunctor(ptr), name, destptr );
    254   return 0;
    255 }
    256 
    257 #define registerStaticNetworkFunction( functionPointer ) \
    258   static void* BOOST_PP_CAT( NETWORK_FUNCTION_, __UNIQUE_NUMBER__ ) = registerStaticNetworkFunctionFct( functionPointer, #functionPointer );
    259 #define registerMemberNetworkFunction( class, function ) \
    260   static void* BOOST_PP_CAT( NETWORK_FUNCTION_##class, __UNIQUE_NUMBER__ ) = registerMemberNetworkFunctionFct<class>( &class::function, #class "_" #function);
    261   // call it with functionPointer, clientID, args
    262 #define callStaticNetworkFunction( functionPointer, ...) \
    263   { \
    264     NetworkFunctionPointer p1; \
    265     copyPtr( functionPointer, p1 ); \
    266     FunctionCallManager::addCallStatic(NetworkFunctionStatic::getFunction(p1)->getNetworkID(), __VA_ARGS__); \
    267   }
    268   // call it with class, function, objectID, clientID, args
    269 #define callMemberNetworkFunction( class, function, objectID, ...) \
    270   { \
    271     NetworkFunctionPointer p1; \
    272     copyPtr( &class::function, p1 ); \
    273     FunctionCallManager::addCallMember(NetworkMemberFunctionBase::getFunction(p1)->getNetworkID(), objectID, __VA_ARGS__); \
    274   }
    275 
    276 
    277 }
    278 
    279211#endif /* _NetworkFunction_H__ */
  • code/trunk/src/libraries/network/NetworkPrereqs.h

    r8858 r10624  
    9797    }
    9898  }
     99
     100  namespace StaticInitialization
     101  {
     102    typedef int Type;
     103    static const Type NETWORK_FUNCTION = 6;
     104  }
    99105}
    100106
  • code/trunk/src/libraries/network/WANDiscoverable.cc

    r10622 r10624  
    3939namespace orxonox
    4040{
     41  RegisterAbstractClass(WANDiscoverable).inheritsFrom<Configurable>();
    4142
    4243  WANDiscoverable::WANDiscoverable(): bActive_(false)
  • code/trunk/src/libraries/network/WANDiscovery.cc

    r10622 r10624  
    3737namespace orxonox
    3838{
     39  RegisterAbstractClass(WANDiscovery).inheritsFrom<Configurable>();
     40
    3941  WANDiscovery::WANDiscovery()
    4042  {
  • code/trunk/src/libraries/network/packet/FunctionCalls.cc

    r8351 r10624  
    8282}
    8383
    84 void FunctionCalls::addCallStatic( uint32_t networkID, const MultiType* mt1, const MultiType* mt2, const MultiType* mt3, const MultiType* mt4, const MultiType* mt5)
     84void FunctionCalls::addCall( uint32_t networkID, uint32_t objectID, const MultiType& mt1, const MultiType& mt2, const MultiType& mt3, const MultiType& mt4, const MultiType& mt5)
    8585{
    8686  assert(!isDataENetAllocated());
    8787 
    8888  this->functionCalls_.push(orxonox::FunctionCall());
    89   this->functionCalls_.back().setCallStatic( networkID, mt1, mt2, mt3, mt4, mt5 );
    90   this->currentSize_ += this->functionCalls_.back().getSize();
    91 }
    92 
    93 void FunctionCalls::addCallMember( uint32_t networkID, uint32_t objectID, const MultiType* mt1, const MultiType* mt2, const MultiType* mt3, const MultiType* mt4, const MultiType* mt5)
    94 {
    95   assert(!isDataENetAllocated());
    96  
    97   this->functionCalls_.push(orxonox::FunctionCall());
    98   this->functionCalls_.back().setCallMember( networkID, objectID, mt1, mt2, mt3, mt4, mt5 );
     89  this->functionCalls_.back().setCall( networkID, objectID, mt1, mt2, mt3, mt4, mt5 );
    9990  this->currentSize_ += this->functionCalls_.back().getSize();
    10091}
  • code/trunk/src/libraries/network/packet/FunctionCalls.h

    r7801 r10624  
    5656  virtual bool process(orxonox::Host* host);
    5757
    58   void addCallStatic( uint32_t networkID, const MultiType* mt1=0, const MultiType* mt2=0, const MultiType* mt3=0, const MultiType* mt4=0, const MultiType* mt5=0);
    59   void addCallMember( uint32_t networkID, uint32_t objectID, const MultiType* mt1=0, const MultiType* mt2=0, const MultiType* mt3=0, const MultiType* mt4=0, const MultiType* mt5=0);
     58  void addCall( uint32_t networkID, uint32_t objectID, const MultiType& mt1, const MultiType& mt2, const MultiType& mt3, const MultiType& mt4, const MultiType& mt5);
    6059  virtual bool send(orxonox::Host* host);
    6160private:
  • code/trunk/src/libraries/network/packet/FunctionIDs.cc

    r9667 r10624  
    3737#include "core/object/ObjectList.h"
    3838#include "network/NetworkFunction.h"
     39#include "network/NetworkFunctionManager.h"
    3940
    4041namespace orxonox {
     
    5556
    5657  //calculate total needed size (for all strings and integers)
    57   ObjectList<NetworkFunctionBase>::iterator it;
    58   for(it = ObjectList<NetworkFunctionBase>::begin(); it; ++it)
     58  const std::set<NetworkFunctionBase*>& set = NetworkFunctionManager::getInstance().getAllFunctions();
     59  std::set<NetworkFunctionBase*>::const_iterator it;
     60  for (it = set.begin(); it != set.end(); ++it)
    5961  {
    60     const std::string& functionname = it->getName();
    61     networkID = it->getNetworkID();
     62    const std::string& functionname = (*it)->getName();
     63    networkID = (*it)->getNetworkID();
    6264    // now push the network id and the classname to the stack
    6365    tempQueue.push( std::pair<unsigned int, std::string>(networkID, functionname) );
     
    126128  unsigned char *functionname;
    127129
     130  //clear the map of network ids
     131  NetworkFunctionManager::getInstance().clearNetworkIDs();
     132
    128133  orxout(verbose, context::packets) << "=== processing functionids: " << endl;
    129134  std::pair<uint32_t, std::string> tempPair;
     
    138143    functionname = temp+2*sizeof(uint32_t);
    139144    orxout(internal_info, context::packets) << "processing functionid: " << networkID << " name: " << functionname << endl;
    140     NetworkFunctionBase::setNetworkID((const char*)functionname, networkID);
     145    NetworkFunctionManager::getInstance().getFunctionByName((const char*)functionname)->setNetworkID(networkID);
    141146    temp += 2*sizeof(uint32_t) + stringsize;
    142147  }
  • code/trunk/src/libraries/network/synchronisable/CMakeLists.txt

    r7314 r10624  
    22  NetworkCallbackManager.cc
    33  Synchronisable.cc
    4   SynchronisableVariable.cc
    54)
    65
  • code/trunk/src/libraries/network/synchronisable/Serialise.h

    r9667 r10624  
    7878    }
    7979
    80     // These functions implement loading / saving / etc. for SmartPtr<T>
     80    // These functions implement loading / saving / etc. for StrongPtr<T>
    8181
    8282    /** @brief returns the size of the objectID needed to synchronise the pointer */
    83     template <class T> inline uint32_t returnSize( const SmartPtr<T>& )
     83    template <class T> inline uint32_t returnSize( const StrongPtr<T>& )
    8484    {
    8585        return sizeof(uint32_t);
     
    8787
    8888    /** @brief reads the objectID of a pointer out of the bytestream and increases the mem pointer */
    89     template <class T> inline void loadAndIncrease( const SmartPtr<T>& variable, uint8_t*& mem )
     89    template <class T> inline void loadAndIncrease( const StrongPtr<T>& variable, uint8_t*& mem )
    9090    {
    9191//         *const_cast<typename Loki::TypeTraits<T*>::UnqualifiedType*>(&variable) = dynamic_cast<T*>(variable->getSynchronisable( *(uint32_t*)(mem) ));
    92         *const_cast<typename Loki::TypeTraits<SmartPtr<T> >::UnqualifiedType*>(&variable) = orxonox_cast<T*>(T::getSynchronisable(*(uint32_t*)(mem)));
     92        *const_cast<typename Loki::TypeTraits<StrongPtr<T> >::UnqualifiedType*>(&variable) = orxonox_cast<T*>(T::getSynchronisable(*(uint32_t*)(mem)));
    9393        mem += returnSize( variable );
    9494    }
    9595
    9696    /** @brief saves the objectID of a pointer into the bytestream and increases the mem pointer */
    97     template <class T> inline void saveAndIncrease( const SmartPtr<T>& variable, uint8_t*& mem )
     97    template <class T> inline void saveAndIncrease( const StrongPtr<T>& variable, uint8_t*& mem )
    9898    {
    9999        if ( variable.get() )
     
    105105
    106106    /** @brief checks whether the objectID of the variable is the same as in the bytestream */
    107     template <class T> inline  bool checkEquality( const SmartPtr<T>& variable, uint8_t* mem )
     107    template <class T> inline  bool checkEquality( const StrongPtr<T>& variable, uint8_t* mem )
    108108    {
    109109        if ( variable.get() )
     
    125125    {
    126126        //         *const_cast<typename Loki::TypeTraits<T*>::UnqualifiedType*>(&variable) = dynamic_cast<T*>(variable->getSynchronisable( *(uint32_t*)(mem) ));
    127         *const_cast<typename Loki::TypeTraits<SmartPtr<T> >::UnqualifiedType*>(&variable) = orxonox_cast<T*>(T::getSynchronisable(*(uint32_t*)(mem)));
     127        *const_cast<typename Loki::TypeTraits<WeakPtr<T> >::UnqualifiedType*>(&variable) = orxonox_cast<T*>(T::getSynchronisable(*(uint32_t*)(mem)));
    128128        mem += returnSize( variable );
    129129    }
  • code/trunk/src/libraries/network/synchronisable/Synchronisable.cc

    r9667 r10624  
    4545  uint8_t Synchronisable::state_=0x1; // detemines wheter we are server (default) or client
    4646
    47   RegisterAbstractClass(Synchronisable).inheritsFrom(Class(OrxonoxInterface));
     47  RegisterAbstractClass(Synchronisable).inheritsFrom<OrxonoxInterface>();
    4848
    4949  /**
     
    151151        for(int i = 0; i<160; i++)
    152152            orxout(user_error, context::network) << "classid: " << i << " identifier: " << ClassByID(i) << endl;
    153         orxout(user_error, context::network) << "Assertion failed: id" << endl;
     153        orxout(user_error, context::network) << "Assertion failed: Could not find Identifier for ClassID " << header.getClassID() << endl;
    154154        orxout(user_error, context::network) << "Possible reason for this error: Client received a synchronizable object whose class has no factory." << endl;
    155155        abort();
     
    182182    no->setClassID(header.getClassID());
    183183    assert(no->contextID_ == header.getContextID());
    184     if( context )
    185     {
    186       BaseObject* boContext = orxonox_cast<BaseObject*>(context);
    187       if (boContext)
    188           bo->setLevel(boContext->getLevel()); // Note: this ensures that the level is known on the client for child objects of the scene (and the scene itself)
    189     }
    190184    //assert(no->classID_ == header.getClassID());
    191185    orxout(verbose, context::network) << "fabricate objectID_: " << no->objectID_ << " classID_: " << no->classID_ << endl;
  • code/trunk/src/libraries/network/synchronisable/SynchronisableVariable.h

    r8858 r10624  
    6565      virtual uint8_t getMode()=0;
    6666      virtual ~SynchronisableVariableBase() {}
    67     protected:
    68       static uint8_t state_;
    6967  };
    7068
     
    108106      variable_( variable ), mode_( syncDirection ), callback_( cb )
    109107  {
    110     if ( state_ == 0x0 )
    111     {
    112       state_ = GameMode::isMaster() ? 0x1 : 0x2;  // set the appropriate mode here
    113     }
    114108  }
    115109
Note: See TracChangeset for help on using the changeset viewer.