Changeset 3304 for code/trunk/src/network
- Timestamp:
- Jul 18, 2009, 6:23:31 PM (16 years ago)
- Location:
- code/trunk
- Files:
-
- 2 deleted
- 21 edited
Legend:
- Unmodified
- Added
- Removed
-
code/trunk
- Property svn:mergeinfo changed
/code/branches/netp6 (added) merged: 3215,3226-3227,3229-3231,3240,3242,3251-3252,3256,3258-3259,3263-3264,3267-3268,3277,3283-3284,3289,3298-3299,3302
- Property svn:mergeinfo changed
-
code/trunk/src/network/CMakeLists.txt
r3214 r3304 31 31 NetworkFunction.cc 32 32 Host.cc 33 PacketBuffer.cc34 33 Server.cc 35 34 ServerConnection.cc -
code/trunk/src/network/ClientInformation.h
r3198 r3304 87 87 static ClientInformation *findClient(ENetAddress *address, bool look_backwards=false); 88 88 static ClientInformation *getBegin(){return head_;} 89 static bool hasClients(){ return ClientInformation::head_!=0; } 89 90 90 91 bool setSynched(bool s); -
code/trunk/src/network/Connection.cc
r3214 r3304 31 31 #include <cassert> 32 32 #include <enet/enet.h> 33 #include <OgreTimer.h>34 33 #include "packet/Packet.h" 35 34 … … 77 76 78 77 assert(this->host_); 79 Ogre::Timer timer;80 78 81 while( timer.getMilliseconds()<NETWORK_MAX_QUEUE_PROCESS_TIME &&enet_host_service( this->host_, &event, NETWORK_WAIT_TIMEOUT ) > 0 )79 while( enet_host_service( this->host_, &event, NETWORK_WAIT_TIMEOUT ) > 0 ) 82 80 { 83 81 switch(event.type){ -
code/trunk/src/network/GamestateClient.cc
r3214 r3304 52 52 53 53 GamestateClient::~GamestateClient() { 54 std::map<unsigned int, packet::Gamestate *>::iterator it; 55 for ( it = this->gamestateMap_.begin(); it != this->gamestateMap_.end(); ++it ) 56 delete (*it).second; 57 if( this->tempGamestate_ ) 58 delete this->tempGamestate_; 54 59 } 55 60 -
code/trunk/src/network/GamestateClient.h
r3301 r3304 73 73 std::map<unsigned int, packet::Gamestate *> gamestateMap_; 74 74 packet::Gamestate *tempGamestate_; // we save the received gamestates here during processQueue 75 unsigned char *shipCache_;76 75 77 76 }; -
code/trunk/src/network/GamestateManager.cc
r3301 r3304 42 42 43 43 #include <cassert> 44 #include <queue> 45 // #include <boost/thread/mutex.hpp> 44 46 45 47 #include "util/Debug.h" 48 #include "core/Executor.h" 49 #include "core/ThreadPool.h" 46 50 #include "ClientInformation.h" 47 51 #include "packet/Acknowledgement.h" … … 56 60 { 57 61 trafficControl_ = new TrafficControl(); 62 // threadMutex_ = new boost::mutex(); 63 // threadPool_ = new ThreadPool(); 58 64 } 59 65 … … 61 67 { 62 68 if( this->reference ) 63 delete this->reference;64 for( std::map<unsigned int, packet::Gamestate*>::iterator it = gamestateQueue.begin(); it != gamestateQueue.end(); it++)69 delete this->reference;std::map<unsigned int, packet::Gamestate*>::iterator it; 70 for( it = gamestateQueue.begin(); it != gamestateQueue.end(); ++it ) 65 71 delete (*it).second; 66 delete trafficControl_; 72 std::map<unsigned int, std::map<unsigned int, packet::Gamestate*> >::iterator it1; 73 std::map<unsigned int, packet::Gamestate*>::iterator it2; 74 for( it1 = gamestateMap_.begin(); it1 != gamestateMap_.end(); ++it1 ) 75 { 76 for( it2 = it1->second.begin(); it2 != it1->second.end(); ++it2 ) 77 delete (*it2).second; 78 } 79 delete this->trafficControl_; 80 // delete this->threadMutex_; 81 // delete this->threadPool_; 67 82 } 68 83 … … 84 99 85 100 bool GamestateManager::processGamestates(){ 101 if( this->gamestateQueue.empty() ) 102 return true; 86 103 std::map<unsigned int, packet::Gamestate*>::iterator it; 87 104 // now push only the most recent gamestates we received (ignore obsolete ones) … … 109 126 return true; 110 127 } 111 112 113 packet::Gamestate *GamestateManager::popGameState(unsigned int clientID) { 128 129 void GamestateManager::sendGamestates() 130 { 131 ClientInformation *temp = ClientInformation::getBegin(); 132 std::queue<packet::Gamestate*> clientGamestates; 133 while(temp != NULL){ 134 if( !(temp->getSynched()) ){ 135 COUT(5) << "Server: not sending gamestate" << std::endl; 136 temp=temp->next(); 137 if(!temp) 138 break; 139 continue; 140 } 141 COUT(4) << "client id: " << temp->getID() << " RTT: " << temp->getRTT() << " loss: " << temp->getPacketLoss() << std::endl; 142 COUT(5) << "Server: doing gamestate gamestate preparation" << std::endl; 143 int cid = temp->getID(); //get client id 144 145 unsigned int gID = temp->getGamestateID(); 146 if(!reference) 147 return; 148 149 packet::Gamestate *client=0; 150 if(gID != GAMESTATEID_INITIAL){ 151 assert(gamestateMap_.find(cid)!=gamestateMap_.end()); 152 std::map<unsigned int, packet::Gamestate*>::iterator it = gamestateMap_[cid].find(gID); 153 if(it!=gamestateMap_[cid].end()) 154 { 155 client = it->second; 156 } 157 } 158 159 clientGamestates.push(0); 160 finishGamestate( cid, &clientGamestates.back(), client, reference ); 161 //FunctorMember<GamestateManager>* functor = 162 // ExecutorMember<GamestateManager>* executor = createExecutor( createFunctor(&GamestateManager::finishGamestate) ); 163 // executor->setObject(this); 164 // executor->setDefaultValues( cid, &clientGamestates.back(), client, reference ); 165 // (*static_cast<Executor*>(executor))(); 166 // this->threadPool_->passFunction( executor, true ); 167 // (*functor)( cid, &(clientGamestates.back()), client, reference ); 168 169 temp = temp->next(); 170 } 171 172 // threadPool_->synchronise(); 173 174 while( !clientGamestates.empty() ) 175 { 176 if(clientGamestates.front()) 177 clientGamestates.front()->send(); 178 clientGamestates.pop(); 179 } 180 } 181 182 183 void GamestateManager::finishGamestate( unsigned int clientID, packet::Gamestate** destgamestate, packet::Gamestate* base, packet::Gamestate* gamestate ) { 114 184 //why are we searching the same client's gamestate id as we searched in 115 185 //Server::sendGameState? 116 packet::Gamestate *gs;117 unsigned int gID = ClientInformation::findClient(clientID)->getGamestateID();118 if(!reference)119 return 0;120 gs = reference->doSelection(clientID, 10000);121 186 // save the (undiffed) gamestate in the clients gamestate map 122 gamestateMap_[clientID][gs->getID()]=gs;123 187 //chose wheather the next gamestate is the first or not 124 packet::Gamestate *client=0; 125 if(gID != GAMESTATEID_INITIAL){ 126 assert(gamestateMap_.find(clientID)!=gamestateMap_.end()); 127 std::map<unsigned int, packet::Gamestate*>::iterator it = gamestateMap_[clientID].find(gID); 128 if(it!=gamestateMap_[clientID].end()) 129 { 130 client = it->second; 131 } 132 } 133 if(client){ 188 189 packet::Gamestate *gs = gamestate->doSelection(clientID, 20000); 190 // packet::Gamestate *gs = new packet::Gamestate(*gamestate); 191 // packet::Gamestate *gs = new packet::Gamestate(); 192 // gs->collectData( id_, 0x1 ); 193 // this->threadMutex_->lock(); 194 gamestateMap_[clientID][gamestate->getID()]=gs; 195 // this->threadMutex_->unlock(); 196 197 if(base) 198 { 199 134 200 // COUT(3) << "diffing" << std::endl; 135 201 // packet::Gamestate* gs1 = gs; 136 packet::Gamestate *diffed = gs->diff( client);202 packet::Gamestate *diffed = gs->diff(base); 137 203 //packet::Gamestate *gs2 = diffed->undiff(gs); 138 204 // assert(*gs == *gs2); … … 143 209 } 144 210 else{ 145 // COUT(3) << "not diffing" << std::endl;146 211 gs = new packet::Gamestate(*gs); 147 212 } 213 214 148 215 bool b = gs->compressData(); 149 216 assert(b); 150 COUT(4) << "sending gamestate with id " << gs->getID(); 151 if(gs->isDiffed()) 152 COUT(4) << " and baseid " << gs->getBaseID() << endl; 153 else 154 COUT(4) << endl; 155 return gs; 217 // COUT(4) << "sending gamestate with id " << gs->getID(); 218 // if(gamestate->isDiffed()) 219 // COUT(4) << " and baseid " << gs->getBaseID() << endl; 220 // else 221 // COUT(4) << endl; 222 gs->setClientID(clientID); 223 *destgamestate = gs; 156 224 } 157 225 … … 175 243 176 244 assert(curid==GAMESTATEID_INITIAL || curid<gamestateID); 177 COUT( 4) << "acking gamestate " << gamestateID << " for clientid: " << clientID << " curid: " << curid << std::endl;245 COUT(5) << "acking gamestate " << gamestateID << " for clientid: " << clientID << " curid: " << curid << std::endl; 178 246 std::map<unsigned int, packet::Gamestate*>::iterator it; 179 247 for(it = gamestateMap_[clientID].begin(); it!=gamestateMap_[clientID].end() && it->first<gamestateID; ){ -
code/trunk/src/network/GamestateManager.h
r3214 r3304 45 45 #include <map> 46 46 #include "GamestateHandler.h" 47 #include "core/CorePrereqs.h" 47 48 48 49 namespace orxonox … … 73 74 bool processGamestates(); 74 75 bool update(); 75 packet::Gamestate *popGameState(unsigned int clientID); 76 void sendGamestates(); 77 // packet::Gamestate *popGameState(unsigned int clientID); 78 void finishGamestate( unsigned int clientID, packet::Gamestate** destgamestate, packet::Gamestate* base, packet::Gamestate* gamestate ); 76 79 77 80 bool getSnapshot(); … … 79 82 bool ack(unsigned int gamestateID, unsigned int clientID); 80 83 void removeClient(ClientInformation *client); 81 84 private: 82 85 bool processGamestate(packet::Gamestate *gs); 83 86 84 87 std::map<unsigned int, std::map<unsigned int, packet::Gamestate*> > gamestateMap_; 85 //std::map<int, packet::Gamestate*> gamestateMap; //map gsID to gamestate*86 //std::map<int, int> gamestateUsed; // save the number of clients, that use the specific gamestate87 88 std::map<unsigned int, packet::Gamestate*> gamestateQueue; 88 89 packet::Gamestate *reference; 89 90 TrafficControl *trafficControl_; 90 91 unsigned int id_; 92 // boost::mutex* threadMutex_; 93 ThreadPool* /*thread*/Pool_; 91 94 }; 92 95 -
code/trunk/src/network/Host.cc
r3214 r3304 74 74 } 75 75 76 77 // bool Host::chat(std::string& message){78 // if(!instance_)79 // return false;80 // packet::Chat *c = new packet::Chat(message, getPlayerID());81 // return instance_->sendChat(c);82 // }83 84 // bool Host::receiveChat(packet::Chat *message, unsigned int clientID){85 // if(instance_)86 // return instance_->processChat(message, clientID);87 // else88 // return false;89 // }90 91 76 /** 92 77 * This function returns the ID of the player -
code/trunk/src/network/NetworkFunction.cc
r3214 r3304 56 56 57 57 58 void NetworkFunctionBase::destroyAllNetworkFunctions() 59 { 60 std::map<std::string, NetworkFunctionBase*>::iterator it; 61 for( it=NetworkFunctionBase::nameMap_.begin(); it!=NetworkFunctionBase::nameMap_.end(); ++it ) 62 delete it->second; 63 } 64 58 65 59 66 NetworkFunctionStatic::NetworkFunctionStatic(FunctorStatic* functor, const std::string& name, const NetworkFunctionPointer& p): -
code/trunk/src/network/NetworkFunction.h
r3214 r3304 37 37 #include <string> 38 38 #include <boost/preprocessor/cat.hpp> 39 #include <boost/static_assert.hpp> 39 40 40 41 #include "core/OrxonoxClass.h" … … 46 47 { 47 48 48 #if def ORXONOX_COMPILER_GCC49 #if defined(ORXONOX_COMPILER_GCC) && defined(ORXONOX_ARCH_32) 49 50 static const unsigned int MAX_FUNCTION_POINTER_SIZE = 8; 50 #else //ORXONOX_COMPILER_GCC51 #else 51 52 static const unsigned int MAX_FUNCTION_POINTER_SIZE = 16; 52 53 #endif //ORXONOX_COMPILER_GCC … … 57 58 bool operator<(const NetworkFunctionPointer& b) const 58 59 { 59 #if def ORXONOX_COMPILER_GCC60 #if defined(ORXONOX_COMPILER_GCC) && defined(ORXONOX_ARCH_32) 60 61 return pointer[0]<b.pointer[0] ? true : pointer[1]<b.pointer[1]; 61 62 #else //ORXONOX_COMPILER_GCC … … 80 81 81 82 static inline void setNetworkID(const std::string& name, uint32_t id){ assert( nameMap_.find(name)!=nameMap_.end() ); nameMap_[name]->setNetworkID(id); } 83 84 static void destroyAllNetworkFunctions(); 82 85 83 86 protected: … … 193 196 template<class T> inline void copyPtr( T ptr, NetworkFunctionPointer& destptr) 194 197 { 195 memset((uint8_t*)&destptr + sizeof(T), 0, sizeof(NetworkFunctionPointer)-sizeof(T)); 198 if( sizeof(NetworkFunctionPointer)-sizeof(T) > 0) 199 memset((uint8_t*)&destptr + sizeof(T), 0, sizeof(NetworkFunctionPointer)-sizeof(T)); 196 200 T p2 = ptr; 197 201 memcpy( &destptr, &p2, sizeof(T) ); … … 202 206 template<class T> inline void* registerStaticNetworkFunctionFct( T ptr, const std::string& name ) 203 207 { 208 BOOST_STATIC_ASSERT( sizeof(T)<=sizeof(NetworkFunctionPointer) ); // if this fails your compiler uses bigger pointers for static functions than defined above 204 209 NetworkFunctionPointer destptr; 205 210 copyPtr( ptr, destptr ); … … 210 215 template<class T, class PT> inline void* registerMemberNetworkFunctionFct( PT ptr, const std::string& name ) 211 216 { 217 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 212 218 NetworkFunctionPointer destptr; 213 219 copyPtr( ptr, destptr ); -
code/trunk/src/network/NetworkPrereqs.h
r3301 r3304 102 102 template <class T> class NetworkMemeberFunction; 103 103 struct NetworkFunctionPointer; 104 class PacketBuffer;105 104 class Server; 106 105 class ServerConnection; -
code/trunk/src/network/Server.cc
r3214 r3304 48 48 #include "core/Clock.h" 49 49 #include "core/ObjectList.h" 50 #include "core/Executor.h" 50 51 #include "packet/Chat.h" 51 52 #include "packet/ClassID.h" … … 68 69 */ 69 70 Server::Server() { 70 timeSinceLastUpdate_=0; 71 gamestates_ = new GamestateManager(); 71 this->timeSinceLastUpdate_=0; 72 72 } 73 73 74 74 Server::Server(int port){ 75 75 this->setPort( port ); 76 timeSinceLastUpdate_=0; 77 gamestates_ = new GamestateManager(); 76 this->timeSinceLastUpdate_=0; 78 77 } 79 78 … … 86 85 this->setPort( port ); 87 86 this->setBindAddress( bindAddress ); 88 timeSinceLastUpdate_=0; 89 gamestates_ = new GamestateManager(); 87 this->timeSinceLastUpdate_=0; 90 88 } 91 89 … … 94 92 */ 95 93 Server::~Server(){ 96 if(gamestates_)97 delete gamestates_;98 94 } 99 95 … … 138 134 */ 139 135 void Server::update(const Clock& time) { 136 // receive incoming packets 140 137 Connection::processQueue(); 141 gamestates_->processGamestates(); 142 //this steers our network frequency 143 timeSinceLastUpdate_+=time.getDeltaTime(); 144 if(timeSinceLastUpdate_>=NETWORK_PERIOD) 138 139 if ( ClientInformation::hasClients() ) 145 140 { 146 timeSinceLastUpdate_ -= static_cast<unsigned int>( timeSinceLastUpdate_ / NETWORK_PERIOD ) * NETWORK_PERIOD; 147 updateGamestate(); 141 // process incoming gamestates 142 GamestateManager::processGamestates(); 143 144 // send function calls to clients 148 145 FunctionCallManager::sendCalls(); 149 } 150 sendPackets(); // flush the enet queue 146 147 //this steers our network frequency 148 timeSinceLastUpdate_+=time.getDeltaTime(); 149 if(timeSinceLastUpdate_>=NETWORK_PERIOD) 150 { 151 timeSinceLastUpdate_ -= static_cast<unsigned int>( timeSinceLastUpdate_ / NETWORK_PERIOD ) * NETWORK_PERIOD; 152 updateGamestate(); 153 } 154 sendPackets(); // flush the enet queue 155 } 151 156 } 152 157 … … 175 180 */ 176 181 void Server::updateGamestate() { 177 //if( ClientInformation::getBegin()==NULL )182 if( ClientInformation::getBegin()==NULL ) 178 183 //no client connected 179 //return;180 gamestates_->update();184 return; 185 GamestateManager::update(); 181 186 COUT(5) << "Server: one gamestate update complete, goig to sendGameState" << std::endl; 182 187 //std::cout << "updated gamestate, sending it" << std::endl; … … 197 202 */ 198 203 bool Server::sendGameState() { 199 COUT(5) << "Server: starting function sendGameState" << std::endl; 200 ClientInformation *temp = ClientInformation::getBegin(); 201 bool added=false; 202 while(temp != NULL){ 203 if( !(temp->getSynched()) ){ 204 COUT(5) << "Server: not sending gamestate" << std::endl; 205 temp=temp->next(); 206 if(!temp) 207 break; 208 //think this works without continue 209 continue; 210 } 211 COUT(4) << "client id: " << temp->getID() << " RTT: " << temp->getRTT() << " loss: " << temp->getPacketLoss() << std::endl; 212 COUT(5) << "Server: doing gamestate gamestate preparation" << std::endl; 213 int gid = temp->getGamestateID(); //get gamestate id 214 int cid = temp->getID(); //get client id 215 COUT(5) << "Server: got acked (gamestate) ID from clientlist: " << gid << std::endl; 216 packet::Gamestate *gs = gamestates_->popGameState(cid); 217 if(gs==NULL){ 218 COUT(2) << "Server: could not generate gamestate (NULL from compress)" << std::endl; 219 temp = temp->next(); 220 continue; 221 } 222 //std::cout << "adding gamestate" << std::endl; 223 gs->setClientID(cid); 224 if ( !gs->send() ){ 225 COUT(3) << "Server: packet with client id (cid): " << cid << " not sended: " << temp->getFailures() << std::endl; 226 temp->addFailure(); 227 }else 228 temp->resetFailures(); 229 added=true; 230 temp=temp->next(); 231 // gs gets automatically deleted by enet callback 232 } 204 // COUT(5) << "Server: starting function sendGameState" << std::endl; 205 // ClientInformation *temp = ClientInformation::getBegin(); 206 // bool added=false; 207 // while(temp != NULL){ 208 // if( !(temp->getSynched()) ){ 209 // COUT(5) << "Server: not sending gamestate" << std::endl; 210 // temp=temp->next(); 211 // if(!temp) 212 // break; 213 // continue; 214 // } 215 // COUT(4) << "client id: " << temp->getID() << " RTT: " << temp->getRTT() << " loss: " << temp->getPacketLoss() << std::endl; 216 // COUT(5) << "Server: doing gamestate gamestate preparation" << std::endl; 217 // int cid = temp->getID(); //get client id 218 // packet::Gamestate *gs = GamestateManager::popGameState(cid); 219 // if(gs==NULL){ 220 // COUT(2) << "Server: could not generate gamestate (NULL from compress)" << std::endl; 221 // temp = temp->next(); 222 // continue; 223 // } 224 // //std::cout << "adding gamestate" << std::endl; 225 // gs->setClientID(cid); 226 // if ( !gs->send() ){ 227 // COUT(3) << "Server: packet with client id (cid): " << cid << " not sended: " << temp->getFailures() << std::endl; 228 // temp->addFailure(); 229 // }else 230 // temp->resetFailures(); 231 // added=true; 232 // temp=temp->next(); 233 // // gs gets automatically deleted by enet callback 234 // } 235 GamestateManager::sendGamestates(); 233 236 return true; 234 237 } … … 324 327 void Server::disconnectClient( ClientInformation *client ){ 325 328 ServerConnection::disconnectClient( client ); 326 gamestates_->removeClient(client);329 GamestateManager::removeClient(client); 327 330 // inform all the listeners 328 331 ObjectList<ClientConnectionListener>::iterator listener = ObjectList<ClientConnectionListener>::begin(); -
code/trunk/src/network/Server.h
r3214 r3304 34 34 #include "core/CorePrereqs.h" 35 35 #include "Host.h" 36 #include "GamestateManager.h" 36 37 #include "ServerConnection.h" 37 38 … … 43 44 * It implements all functions necessary for a Server 44 45 */ 45 class _NetworkExport Server : public Host, public ServerConnection {46 class _NetworkExport Server : public Host, public ServerConnection, public GamestateManager{ 46 47 public: 47 48 Server(); … … 63 64 unsigned int shipID(){return 0;} 64 65 unsigned int playerID(){return 0;} 65 66 66 67 void addClient(ENetEvent *event); 67 68 bool createClient(int clientID); … … 75 76 void syncClassid(unsigned int clientID); 76 77 77 GamestateManager *gamestates_;78 79 80 78 float timeSinceLastUpdate_; 81 79 }; -
code/trunk/src/network/packet/ClassID.cc
r3280 r3304 142 142 classname = temp+2*sizeof(uint32_t); 143 143 id=ClassByString( std::string((const char*)classname) ); 144 COUT( 0) << "processing classid: " << networkID << " name: " << classname << " id: " << id << std::endl;144 COUT(3) << "processing classid: " << networkID << " name: " << classname << " id: " << id << std::endl; 145 145 if(id==NULL){ 146 146 COUT(0) << "Recieved a bad classname" << endl; -
code/trunk/src/network/packet/FunctionIDs.cc
r3280 r3304 132 132 stringsize = *(uint32_t*)(temp+sizeof(uint32_t)); 133 133 functionname = temp+2*sizeof(uint32_t); 134 COUT( 0) << "processing functionid: " << networkID << " name: " << functionname << std::endl;134 COUT(3) << "processing functionid: " << networkID << " name: " << functionname << std::endl; 135 135 NetworkFunctionBase::setNetworkID((const char*)functionname, networkID); 136 136 temp += 2*sizeof(uint32_t) + stringsize; -
code/trunk/src/network/synchronisable/NetworkCallbackManager.cc
r3214 r3304 44 44 if (it != callbackSet_.end()) 45 45 { 46 delete (*it);47 46 callbackSet_.erase(it); 47 delete cb; 48 48 } 49 49 } -
code/trunk/src/network/synchronisable/Synchronisable.cc
r3280 r3304 96 96 if (this->objectMode_ != 0x0 && (Host::running() && Host::isServer())) 97 97 deletedObjects_.push(objectID); 98 // delete all Synchronisable Variables from syncList ( which are also in stringList )99 for(std::vector<SynchronisableVariableBase*>::iterator it = syncList.begin(); it!=syncList.end(); it++)100 delete (*it);101 syncList.clear();102 stringList.clear();103 }98 } 99 // delete all Synchronisable Variables from syncList ( which are also in stringList ) 100 for(std::vector<SynchronisableVariableBase*>::iterator it = syncList.begin(); it!=syncList.end(); it++) 101 delete (*it); 102 syncList.clear(); 103 stringList.clear(); 104 104 std::map<uint32_t, Synchronisable*>::iterator it; 105 105 it = objectMap_.find(objectID); … … 247 247 return 0; 248 248 uint32_t tempsize = 0; 249 #ifndef NDEBUG 249 250 if (this->classID==0) 250 251 COUT(3) << "classid 0 " << this->getIdentifier()->getName() << std::endl; 252 #endif 251 253 252 254 if (this->classID == static_cast<uint32_t>(-1)) -
code/trunk/src/network/synchronisable/Synchronisable.h
r3301 r3304 43 43 #include "NetworkCallback.h" 44 44 45 /*#define REGISTERDATA(varname, ...) \46 registerVariable(static_cast<void*>(&varname), sizeof(varname), DATA, __VA_ARGS__)47 #define REGISTERSTRING(stringname, ...) \48 registerVariable(&stringname, stringname.length()+1, STRING, __VA_ARGS__)*/49 45 50 46 namespace orxonox -
code/trunk/src/network/synchronisable/SynchronisableSpecialisations.cc
r3214 r3304 38 38 namespace orxonox{ 39 39 40 // template <> void Synchronisable::registerVariable( const std::string& variable, uint8_t mode, NetworkCallbackBase *cb, bool bidirectional)41 // {42 // if (bidirectional)43 // syncList.push_back(new SynchronisableVariableBidirectional<const std::string>(variable, mode, cb));44 // else45 // syncList.push_back(new SynchronisableVariable<const std::string>(variable, mode, cb));46 // stringList.push_back(syncList.back());47 // }48 49 40 template <> void Synchronisable::registerVariable( std::string& variable, uint8_t mode, NetworkCallbackBase *cb, bool bidirectional) 50 41 { 42 SynchronisableVariableBase* sv; 51 43 if (bidirectional) 52 s yncList.push_back(new SynchronisableVariableBidirectional<const std::string>(variable, mode, cb));44 sv = new SynchronisableVariableBidirectional<const std::string>(variable, mode, cb); 53 45 else 54 syncList.push_back(new SynchronisableVariable<const std::string>(variable, mode, cb)); 55 stringList.push_back(syncList.back()); 46 sv = new SynchronisableVariable<const std::string>(variable, mode, cb); 47 syncList.push_back(sv); 48 stringList.push_back(sv); 56 49 } 57 50 … … 73 66 registerVariable(variable.y, mode, cb, bidirectional); 74 67 } 75 // template <> void Synchronisable::registerVariable( Vector2& variable, uint8_t mode, NetworkCallbackBase* cb, bool bidirectional)76 // {77 // registerVariable( (const ColourValue&)variable, mode, cb, bidirectional);78 // }79 68 80 69 template <> void Synchronisable::registerVariable( const Vector3& variable, uint8_t mode, NetworkCallbackBase* cb, bool bidirectional) -
code/trunk/src/network/synchronisable/SynchronisableVariable.h
r3301 r3304 117 117 { 118 118 if (this->callback_ != 0) 119 { 119 120 NetworkCallbackManager::deleteCallback(this->callback_); //safe call for deletion 121 // this is neccessary because for example for a Vector3 all 3 components of the vector use the same callback 122 } 120 123 } 121 124
Note: See TracChangeset
for help on using the changeset viewer.