Changeset 10624 for code/trunk/src/libraries/network
- Timestamp:
- Oct 4, 2015, 9:12:21 PM (9 years ago)
- 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 34 34 MasterServerComm.cc 35 35 NetworkFunction.cc 36 NetworkFunctionIncludes.cc 37 NetworkFunctionManager.cc 38 NetworkStaticInitializationHandler.cc 36 39 Host.cc 37 40 Server.cc … … 43 46 ) 44 47 45 SET_SOURCE_FILES(NETWORK_HDR_FILES46 Client.h47 ClientConnection.h48 ClientConnectionListener.h49 Connection.h50 FunctionCall.h51 FunctionCallManager.h52 #GamestateClient.h53 GamestateHandler.h54 GamestateManager.h55 Host.h56 LANDiscoverable.h57 LANDiscovery.h58 WANDiscoverable.h59 WANDiscovery.h60 MasterServerComm.h61 NetworkChatListener.h62 NetworkFunction.h63 NetworkPrecompiledHeaders.h64 NetworkPrereqs.h65 Server.h66 MasterServer.h67 PeerList.h68 ServerList.h69 ServerConnection.h70 TrafficControl.h71 )72 73 48 ADD_SUBDIRECTORY(packet) 74 49 ADD_SUBDIRECTORY(synchronisable) 75 50 76 51 ORXONOX_ADD_LIBRARY(network 52 FIND_HEADER_FILES 77 53 TOLUA_FILES 78 54 Client.h … … 90 66 core 91 67 SOURCE_FILES 92 ${NETWORK_SRC_FILES} ${NETWORK_HDR_FILES}68 ${NETWORK_SRC_FILES} 93 69 ) -
code/trunk/src/libraries/network/Client.cc
r9667 r10624 45 45 #include "util/Clock.h" 46 46 #include "util/Output.h" 47 #include "util/ScopedSingletonManager.h"48 47 #include "synchronisable/Synchronisable.h" 49 48 #include "packet/Chat.h" … … 52 51 #include "core/CoreIncludes.h" 53 52 #include "core/Game.h" 54 #include "core/config/CommandLineParser.h" 53 #include "core/commandline/CommandLineParser.h" 54 #include "core/singleton/ScopedSingletonIncludes.h" 55 55 56 56 namespace orxonox 57 57 { 58 58 59 ManageScopedSingleton( Client, ScopeID::R oot, true );59 ManageScopedSingleton( Client, ScopeID::ROOT, false ); 60 60 61 61 /** … … 194 194 void Client::connectionClosed() 195 195 { 196 ObjectList<Synchronisable>::iterator it;197 for(it = ObjectList<Synchronisable>::begin(); it; )198 {199 if( it->getSyncMode() != 0x0 )200 (it++)->destroy();201 else202 {203 ++it;204 }205 }206 196 Game::getInstance().popState(); 207 197 Game::getInstance().popState(); -
code/trunk/src/libraries/network/ClientConnectionListener.cc
r9667 r10624 35 35 namespace orxonox 36 36 { 37 RegisterAbstractClass(ClientConnectionListener).inheritsFrom (Class(Listable));37 RegisterAbstractClass(ClientConnectionListener).inheritsFrom<Listable>(); 38 38 39 39 ClientConnectionListener::ClientConnectionListener() -
code/trunk/src/libraries/network/FunctionCall.cc
r7503 r10624 32 32 #include "util/MultiType.h" 33 33 #include "NetworkFunction.h" 34 #include "NetworkFunctionManager.h" 34 35 35 36 namespace orxonox { … … 46 47 47 48 bool 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_) 49 53 { 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 75 69 } 76 else // not a static function, so also handle with the objectID77 {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;110 70 } 111 71 112 void FunctionCall::setCall Static( uint32_t networkID, const MultiType* mt1, const MultiType* mt2, const MultiType* mt3, const MultiType* mt4, const MultiType*mt5){72 void FunctionCall::setCall( uint32_t networkID, uint32_t objectID, const MultiType& mt1, const MultiType& mt2, const MultiType& mt3, const MultiType& mt4, const MultiType& mt5){ 113 73 114 74 // 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 isStatic75 uint32_t callsize = 3*sizeof(uint32_t); //size for network-function-id and nrOfArguments and the objectID 116 76 uint32_t nrOfArguments = 0; 117 if( mt1)77 if(!mt1.null()) 118 78 { 119 79 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()) 123 83 { 124 84 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()) 128 88 { 129 89 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()) 133 93 { 134 94 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()) 138 98 { 139 99 nrOfArguments++; 140 callsize += mt5 ->getNetworkSize();141 this->arguments_.push_back( *mt5);100 callsize += mt5.getNetworkSize(); 101 this->arguments_.push_back(mt5); 142 102 } 143 103 } … … 146 106 } 147 107 this->nrOfArguments_ = nrOfArguments; 108 this->functionID_ = networkID; 109 this->objectID_ = objectID; 148 110 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 call156 uint32_t callsize = 3*sizeof(uint32_t)+sizeof(uint8_t); //size for network-function-id and nrOfArguments and the objectID and bIsStatic157 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;193 111 } 194 112 … … 196 114 { 197 115 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); 209 119 for( unsigned int i=0; i<this->nrOfArguments_; ++i ) 210 120 { … … 218 128 // now serialise the mt values and copy the function id and isStatic 219 129 *(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); 231 133 for( std::vector<MultiType>::iterator it = this->arguments_.begin(); it!=this->arguments_.end(); ++it ) 232 134 { -
code/trunk/src/libraries/network/FunctionCall.h
r7495 r10624 52 52 bool execute(); 53 53 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); 56 55 57 56 void saveData( uint8_t*& mem ); … … 59 58 private: 60 59 uint32_t nrOfArguments_; 61 bool bIsStatic_;62 60 uint32_t functionID_; 63 uint32_t objectID_; 61 uint32_t objectID_; // equals OBJECTID_UNKNOWN for static functions 64 62 uint32_t size_; 65 63 std::vector<MultiType> arguments_; -
code/trunk/src/libraries/network/FunctionCallManager.cc
r8403 r10624 39 39 std::vector<std::pair<FunctionCall, std::pair<uint32_t, uint32_t> > > FunctionCallManager::sIncomingFunctionCallBuffer_; 40 40 41 // Static calls42 41 43 void FunctionCallManager::addCall Static(uint32_t functionID, uint32_t peerID)42 void 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) 44 43 { 45 44 if(sPeerMap_.find(peerID)==sPeerMap_.end()) … … 48 47 FunctionCallManager::sPeerMap_[peerID]->setPeerID(peerID); 49 48 } 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); 154 50 } 155 51 -
code/trunk/src/libraries/network/FunctionCallManager.h
r7801 r10624 46 46 { 47 47 public: 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); 61 49 62 50 static void sendCalls(orxonox::Host* host); -
code/trunk/src/libraries/network/Host.cc
r9667 r10624 34 34 #include "core/CoreIncludes.h" 35 35 #include "core/object/ObjectList.h" 36 #include "core/command/ConsoleCommand .h"36 #include "core/command/ConsoleCommandIncludes.h" 37 37 #include "NetworkChatListener.h" 38 38 … … 143 143 ////////////////////////////////////////////////////////////////////////// 144 144 145 RegisterAbstractClass(NetworkChatListener).inheritsFrom<Listable>(); 146 145 147 NetworkChatListener::NetworkChatListener() 146 148 { -
code/trunk/src/libraries/network/LANDiscovery.cc
r10622 r10624 32 32 #include <cstring> 33 33 34 #include "util/ScopedSingletonManager.h"35 34 #include "core/CoreIncludes.h" 35 #include "core/singleton/ScopedSingletonIncludes.h" 36 36 37 37 38 38 namespace orxonox 39 39 { 40 ManageScopedSingleton(LANDiscovery, ScopeID::G raphics, true);40 ManageScopedSingleton(LANDiscovery, ScopeID::GRAPHICS, false); 41 41 42 42 LANDiscovery::LANDiscovery() -
code/trunk/src/libraries/network/MasterServer.cc
r10622 r10624 28 28 29 29 #include "MasterServer.h" 30 #include "util/ScopedSingletonManager.h" 31 #include "core/command/ConsoleCommand.h" 30 #include "core/command/ConsoleCommandIncludes.h" 32 31 #include "core/CoreIncludes.h" 33 32 #include "core/CorePrereqs.h" 33 #include "core/singleton/ScopedSingletonIncludes.h" 34 34 #include "util/Output.h" 35 35 -
code/trunk/src/libraries/network/NetworkFunction.cc
r9667 r10624 28 28 29 29 #include "NetworkFunction.h" 30 #include " core/CoreIncludes.h"30 #include "NetworkFunctionManager.h" 31 31 32 32 namespace orxonox 33 33 { 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 } 35 41 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 } 112 47 } -
code/trunk/src/libraries/network/NetworkFunction.h
r9667 r10624 36 36 #include <map> 37 37 #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 43 39 #include "core/command/Functor.h" 44 40 #include "FunctionCallManager.h" … … 60 56 { 61 57 #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 66 76 } 67 77 }; … … 71 81 72 82 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 // 83 class _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 142 93 virtual bool call(uint32_t objectID)=0; 143 94 virtual bool call(uint32_t objectID, const MultiType& mt1)=0; … … 148 99 149 100 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 108 class _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 129 class _NetworkExport NetworkMemberFunctionBase: public NetworkFunctionBase { 130 public: 131 NetworkMemberFunctionBase(const std::string& name, const NetworkFunctionPointer& p) 132 : NetworkFunctionBase(name, p) 133 { } 152 134 }; 153 135 … … 155 137 template <class T> class NetworkMemberFunction: public NetworkMemberFunctionBase { 156 138 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 { } 158 143 159 144 inline bool call(uint32_t objectID) … … 222 207 }; 223 208 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 {227 209 } 228 210 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 above242 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 above251 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, args262 #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, args269 #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 279 211 #endif /* _NetworkFunction_H__ */ -
code/trunk/src/libraries/network/NetworkPrereqs.h
r8858 r10624 97 97 } 98 98 } 99 100 namespace StaticInitialization 101 { 102 typedef int Type; 103 static const Type NETWORK_FUNCTION = 6; 104 } 99 105 } 100 106 -
code/trunk/src/libraries/network/WANDiscoverable.cc
r10622 r10624 39 39 namespace orxonox 40 40 { 41 RegisterAbstractClass(WANDiscoverable).inheritsFrom<Configurable>(); 41 42 42 43 WANDiscoverable::WANDiscoverable(): bActive_(false) -
code/trunk/src/libraries/network/WANDiscovery.cc
r10622 r10624 37 37 namespace orxonox 38 38 { 39 RegisterAbstractClass(WANDiscovery).inheritsFrom<Configurable>(); 40 39 41 WANDiscovery::WANDiscovery() 40 42 { -
code/trunk/src/libraries/network/packet/FunctionCalls.cc
r8351 r10624 82 82 } 83 83 84 void FunctionCalls::addCall Static( uint32_t networkID, const MultiType* mt1, const MultiType* mt2, const MultiType* mt3, const MultiType* mt4, const MultiType*mt5)84 void FunctionCalls::addCall( uint32_t networkID, uint32_t objectID, const MultiType& mt1, const MultiType& mt2, const MultiType& mt3, const MultiType& mt4, const MultiType& mt5) 85 85 { 86 86 assert(!isDataENetAllocated()); 87 87 88 88 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 ); 99 90 this->currentSize_ += this->functionCalls_.back().getSize(); 100 91 } -
code/trunk/src/libraries/network/packet/FunctionCalls.h
r7801 r10624 56 56 virtual bool process(orxonox::Host* host); 57 57 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); 60 59 virtual bool send(orxonox::Host* host); 61 60 private: -
code/trunk/src/libraries/network/packet/FunctionIDs.cc
r9667 r10624 37 37 #include "core/object/ObjectList.h" 38 38 #include "network/NetworkFunction.h" 39 #include "network/NetworkFunctionManager.h" 39 40 40 41 namespace orxonox { … … 55 56 56 57 //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) 59 61 { 60 const std::string& functionname = it->getName();61 networkID = it->getNetworkID();62 const std::string& functionname = (*it)->getName(); 63 networkID = (*it)->getNetworkID(); 62 64 // now push the network id and the classname to the stack 63 65 tempQueue.push( std::pair<unsigned int, std::string>(networkID, functionname) ); … … 126 128 unsigned char *functionname; 127 129 130 //clear the map of network ids 131 NetworkFunctionManager::getInstance().clearNetworkIDs(); 132 128 133 orxout(verbose, context::packets) << "=== processing functionids: " << endl; 129 134 std::pair<uint32_t, std::string> tempPair; … … 138 143 functionname = temp+2*sizeof(uint32_t); 139 144 orxout(internal_info, context::packets) << "processing functionid: " << networkID << " name: " << functionname << endl; 140 NetworkFunction Base::setNetworkID((const char*)functionname,networkID);145 NetworkFunctionManager::getInstance().getFunctionByName((const char*)functionname)->setNetworkID(networkID); 141 146 temp += 2*sizeof(uint32_t) + stringsize; 142 147 } -
code/trunk/src/libraries/network/synchronisable/CMakeLists.txt
r7314 r10624 2 2 NetworkCallbackManager.cc 3 3 Synchronisable.cc 4 SynchronisableVariable.cc5 4 ) 6 5 -
code/trunk/src/libraries/network/synchronisable/Serialise.h
r9667 r10624 78 78 } 79 79 80 // These functions implement loading / saving / etc. for S martPtr<T>80 // These functions implement loading / saving / etc. for StrongPtr<T> 81 81 82 82 /** @brief returns the size of the objectID needed to synchronise the pointer */ 83 template <class T> inline uint32_t returnSize( const S martPtr<T>& )83 template <class T> inline uint32_t returnSize( const StrongPtr<T>& ) 84 84 { 85 85 return sizeof(uint32_t); … … 87 87 88 88 /** @brief reads the objectID of a pointer out of the bytestream and increases the mem pointer */ 89 template <class T> inline void loadAndIncrease( const S martPtr<T>& variable, uint8_t*& mem )89 template <class T> inline void loadAndIncrease( const StrongPtr<T>& variable, uint8_t*& mem ) 90 90 { 91 91 // *const_cast<typename Loki::TypeTraits<T*>::UnqualifiedType*>(&variable) = dynamic_cast<T*>(variable->getSynchronisable( *(uint32_t*)(mem) )); 92 *const_cast<typename Loki::TypeTraits<S martPtr<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))); 93 93 mem += returnSize( variable ); 94 94 } 95 95 96 96 /** @brief saves the objectID of a pointer into the bytestream and increases the mem pointer */ 97 template <class T> inline void saveAndIncrease( const S martPtr<T>& variable, uint8_t*& mem )97 template <class T> inline void saveAndIncrease( const StrongPtr<T>& variable, uint8_t*& mem ) 98 98 { 99 99 if ( variable.get() ) … … 105 105 106 106 /** @brief checks whether the objectID of the variable is the same as in the bytestream */ 107 template <class T> inline bool checkEquality( const S martPtr<T>& variable, uint8_t* mem )107 template <class T> inline bool checkEquality( const StrongPtr<T>& variable, uint8_t* mem ) 108 108 { 109 109 if ( variable.get() ) … … 125 125 { 126 126 // *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))); 128 128 mem += returnSize( variable ); 129 129 } -
code/trunk/src/libraries/network/synchronisable/Synchronisable.cc
r9667 r10624 45 45 uint8_t Synchronisable::state_=0x1; // detemines wheter we are server (default) or client 46 46 47 RegisterAbstractClass(Synchronisable).inheritsFrom (Class(OrxonoxInterface));47 RegisterAbstractClass(Synchronisable).inheritsFrom<OrxonoxInterface>(); 48 48 49 49 /** … … 151 151 for(int i = 0; i<160; i++) 152 152 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; 154 154 orxout(user_error, context::network) << "Possible reason for this error: Client received a synchronizable object whose class has no factory." << endl; 155 155 abort(); … … 182 182 no->setClassID(header.getClassID()); 183 183 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 }190 184 //assert(no->classID_ == header.getClassID()); 191 185 orxout(verbose, context::network) << "fabricate objectID_: " << no->objectID_ << " classID_: " << no->classID_ << endl; -
code/trunk/src/libraries/network/synchronisable/SynchronisableVariable.h
r8858 r10624 65 65 virtual uint8_t getMode()=0; 66 66 virtual ~SynchronisableVariableBase() {} 67 protected:68 static uint8_t state_;69 67 }; 70 68 … … 108 106 variable_( variable ), mode_( syncDirection ), callback_( cb ) 109 107 { 110 if ( state_ == 0x0 )111 {112 state_ = GameMode::isMaster() ? 0x1 : 0x2; // set the appropriate mode here113 }114 108 } 115 109
Note: See TracChangeset
for help on using the changeset viewer.