Changeset 7495 for code/trunk/src/libraries
- Timestamp:
- Sep 28, 2010, 9:48:32 PM (14 years ago)
- Location:
- code/trunk/src/libraries/network
- Files:
-
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
code/trunk/src/libraries/network/Client.cc
r7284 r7495 175 175 if(gamestate->processGamestates()) 176 176 { 177 FunctionCallManager::processBufferedFunctionCalls(); 177 178 if(!isSynched_) 178 179 isSynched_=true; -
code/trunk/src/libraries/network/FunctionCall.cc
r7490 r7495 80 80 { 81 81 case 0: 82 fct->call(this->objectID_); 82 if( !fct->call(this->objectID_) ) 83 return false; 83 84 break; 84 85 case 1: 85 fct->call(this->objectID_, this->arguments_[0]); 86 if( !fct->call(this->objectID_, this->arguments_[0]) ) 87 return false; 86 88 break; 87 89 case 2: 88 fct->call(this->objectID_, this->arguments_[0], this->arguments_[1]); 90 if( !fct->call(this->objectID_, this->arguments_[0], this->arguments_[1]) ) 91 return false; 89 92 break; 90 93 case 3: 91 fct->call(this->objectID_, this->arguments_[0], this->arguments_[1], this->arguments_[2]); 94 if( !fct->call(this->objectID_, this->arguments_[0], this->arguments_[1], this->arguments_[2]) ) 95 return false; 92 96 break; 93 97 case 4: 94 fct->call(this->objectID_, this->arguments_[0], this->arguments_[1], this->arguments_[2], this->arguments_[3]); 98 if( !fct->call(this->objectID_, this->arguments_[0], this->arguments_[1], this->arguments_[2], this->arguments_[3]) ) 99 return false; 95 100 break; 96 101 case 5: 97 fct->call(this->objectID_, this->arguments_[0], this->arguments_[1], this->arguments_[2], this->arguments_[3], this->arguments_[4]); 102 if( !fct->call(this->objectID_, this->arguments_[0], this->arguments_[1], this->arguments_[2], this->arguments_[3], this->arguments_[4]) ) 103 return false; 98 104 break; 99 105 default: -
code/trunk/src/libraries/network/FunctionCall.h
r7490 r7495 32 32 #include "network/NetworkPrereqs.h" 33 33 #include "util/UtilPrereqs.h" 34 #include "util/MultiType.h" 34 35 35 36 #include <cassert> -
code/trunk/src/libraries/network/FunctionCallManager.cc
r6417 r7495 29 29 #include "FunctionCallManager.h" 30 30 #include "packet/FunctionCalls.h" 31 #include "core/GameMode.h" 31 32 32 33 namespace orxonox { 33 34 34 std::map<uint32_t, packet::FunctionCalls*> FunctionCallManager::clientMap_; 35 std::map<uint32_t, packet::FunctionCalls*> FunctionCallManager::sClientMap_; 36 std::vector<FunctionCall> FunctionCallManager::sIncomingFunctionCallBuffer_; 35 37 36 38 // Static calls … … 38 40 void FunctionCallManager::addCallStatic(uint32_t functionID, uint32_t clientID) 39 41 { 40 if( clientMap_.find(clientID)==clientMap_.end())42 if(sClientMap_.find(clientID)==sClientMap_.end()) 41 43 { 42 FunctionCallManager:: clientMap_[clientID] = new packet::FunctionCalls;43 FunctionCallManager:: clientMap_[clientID]->setClientID(clientID);44 FunctionCallManager::sClientMap_[clientID] = new packet::FunctionCalls; 45 FunctionCallManager::sClientMap_[clientID]->setClientID(clientID); 44 46 } 45 FunctionCallManager:: clientMap_[clientID]->addCallStatic(functionID);47 FunctionCallManager::sClientMap_[clientID]->addCallStatic(functionID); 46 48 } 47 49 void FunctionCallManager::addCallStatic(uint32_t functionID, uint32_t clientID, const MultiType& mt1) 48 50 { 49 if( clientMap_.find(clientID)==clientMap_.end())51 if(sClientMap_.find(clientID)==sClientMap_.end()) 50 52 { 51 FunctionCallManager:: clientMap_[clientID] = new packet::FunctionCalls;52 FunctionCallManager:: clientMap_[clientID]->setClientID(clientID);53 FunctionCallManager::sClientMap_[clientID] = new packet::FunctionCalls; 54 FunctionCallManager::sClientMap_[clientID]->setClientID(clientID); 53 55 } 54 FunctionCallManager:: clientMap_[clientID]->addCallStatic(functionID, &mt1);56 FunctionCallManager:: sClientMap_[clientID]->addCallStatic(functionID, &mt1); 55 57 } 56 58 void FunctionCallManager::addCallStatic(uint32_t functionID, uint32_t clientID, const MultiType& mt1, const MultiType& mt2) 57 59 { 58 if( clientMap_.find(clientID)==clientMap_.end())60 if(sClientMap_.find(clientID)==sClientMap_.end()) 59 61 { 60 FunctionCallManager:: clientMap_[clientID] = new packet::FunctionCalls;61 FunctionCallManager:: clientMap_[clientID]->setClientID(clientID);62 FunctionCallManager::sClientMap_[clientID] = new packet::FunctionCalls; 63 FunctionCallManager::sClientMap_[clientID]->setClientID(clientID); 62 64 } 63 FunctionCallManager:: clientMap_[clientID]->addCallStatic(functionID, &mt1, &mt2);65 FunctionCallManager:: sClientMap_[clientID]->addCallStatic(functionID, &mt1, &mt2); 64 66 } 65 67 void FunctionCallManager::addCallStatic(uint32_t functionID, uint32_t clientID, const MultiType& mt1, const MultiType& mt2, const MultiType& mt3) 66 68 { 67 if( clientMap_.find(clientID)==clientMap_.end())69 if(sClientMap_.find(clientID)==sClientMap_.end()) 68 70 { 69 FunctionCallManager:: clientMap_[clientID] = new packet::FunctionCalls;70 FunctionCallManager:: clientMap_[clientID]->setClientID(clientID);71 FunctionCallManager::sClientMap_[clientID] = new packet::FunctionCalls; 72 FunctionCallManager::sClientMap_[clientID]->setClientID(clientID); 71 73 } 72 FunctionCallManager:: clientMap_[clientID]->addCallStatic(functionID, &mt1, &mt2, &mt3);74 FunctionCallManager:: sClientMap_[clientID]->addCallStatic(functionID, &mt1, &mt2, &mt3); 73 75 } 74 76 void FunctionCallManager::addCallStatic(uint32_t functionID, uint32_t clientID, const MultiType& mt1, const MultiType& mt2, const MultiType& mt3, const MultiType& mt4) 75 77 { 76 if( clientMap_.find(clientID)==clientMap_.end())78 if(sClientMap_.find(clientID)==sClientMap_.end()) 77 79 { 78 FunctionCallManager:: clientMap_[clientID] = new packet::FunctionCalls;79 FunctionCallManager:: clientMap_[clientID]->setClientID(clientID);80 FunctionCallManager::sClientMap_[clientID] = new packet::FunctionCalls; 81 FunctionCallManager::sClientMap_[clientID]->setClientID(clientID); 80 82 } 81 FunctionCallManager:: clientMap_[clientID]->addCallStatic(functionID, &mt1, &mt2, &mt3, &mt4);83 FunctionCallManager:: sClientMap_[clientID]->addCallStatic(functionID, &mt1, &mt2, &mt3, &mt4); 82 84 } 83 85 void FunctionCallManager::addCallStatic(uint32_t functionID, uint32_t clientID, const MultiType& mt1, const MultiType& mt2, const MultiType& mt3, const MultiType& mt4, const MultiType& mt5) 84 86 { 85 if( clientMap_.find(clientID)==clientMap_.end())87 if(sClientMap_.find(clientID)==sClientMap_.end()) 86 88 { 87 FunctionCallManager:: clientMap_[clientID] = new packet::FunctionCalls;88 FunctionCallManager:: clientMap_[clientID]->setClientID(clientID);89 FunctionCallManager::sClientMap_[clientID] = new packet::FunctionCalls; 90 FunctionCallManager::sClientMap_[clientID]->setClientID(clientID); 89 91 } 90 FunctionCallManager:: clientMap_[clientID]->addCallStatic(functionID, &mt1, &mt2, &mt3, &mt4, &mt5);92 FunctionCallManager:: sClientMap_[clientID]->addCallStatic(functionID, &mt1, &mt2, &mt3, &mt4, &mt5); 91 93 } 92 94 … … 96 98 void FunctionCallManager::addCallMember(uint32_t functionID, uint32_t objectID, uint32_t clientID) 97 99 { 98 if( clientMap_.find(clientID)==clientMap_.end())100 if(sClientMap_.find(clientID)==sClientMap_.end()) 99 101 { 100 FunctionCallManager:: clientMap_[clientID] = new packet::FunctionCalls;101 FunctionCallManager:: clientMap_[clientID]->setClientID(clientID);102 FunctionCallManager::sClientMap_[clientID] = new packet::FunctionCalls; 103 FunctionCallManager::sClientMap_[clientID]->setClientID(clientID); 102 104 } 103 FunctionCallManager:: clientMap_[clientID]->addCallMember(functionID, objectID);105 FunctionCallManager::sClientMap_[clientID]->addCallMember(functionID, objectID); 104 106 } 105 107 void FunctionCallManager::addCallMember(uint32_t functionID, uint32_t objectID, uint32_t clientID, const MultiType& mt1) 106 108 { 107 if( clientMap_.find(clientID)==clientMap_.end())109 if(sClientMap_.find(clientID)==sClientMap_.end()) 108 110 { 109 FunctionCallManager:: clientMap_[clientID] = new packet::FunctionCalls;110 FunctionCallManager:: clientMap_[clientID]->setClientID(clientID);111 FunctionCallManager::sClientMap_[clientID] = new packet::FunctionCalls; 112 FunctionCallManager::sClientMap_[clientID]->setClientID(clientID); 111 113 } 112 FunctionCallManager:: clientMap_[clientID]->addCallMember(functionID, objectID, &mt1);114 FunctionCallManager::sClientMap_[clientID]->addCallMember(functionID, objectID, &mt1); 113 115 } 114 116 void FunctionCallManager::addCallMember(uint32_t functionID, uint32_t objectID, uint32_t clientID, const MultiType& mt1, const MultiType& mt2) 115 117 { 116 if( clientMap_.find(clientID)==clientMap_.end())118 if(sClientMap_.find(clientID)==sClientMap_.end()) 117 119 { 118 FunctionCallManager:: clientMap_[clientID] = new packet::FunctionCalls;119 FunctionCallManager:: clientMap_[clientID]->setClientID(clientID);120 FunctionCallManager::sClientMap_[clientID] = new packet::FunctionCalls; 121 FunctionCallManager::sClientMap_[clientID]->setClientID(clientID); 120 122 } 121 FunctionCallManager:: clientMap_[clientID]->addCallMember(functionID, objectID, &mt1, &mt2);123 FunctionCallManager::sClientMap_[clientID]->addCallMember(functionID, objectID, &mt1, &mt2); 122 124 } 123 125 void FunctionCallManager::addCallMember(uint32_t functionID, uint32_t objectID, uint32_t clientID, const MultiType& mt1, const MultiType& mt2, const MultiType& mt3) 124 126 { 125 if( clientMap_.find(clientID)==clientMap_.end())127 if(sClientMap_.find(clientID)==sClientMap_.end()) 126 128 { 127 FunctionCallManager:: clientMap_[clientID] = new packet::FunctionCalls;128 FunctionCallManager:: clientMap_[clientID]->setClientID(clientID);129 FunctionCallManager::sClientMap_[clientID] = new packet::FunctionCalls; 130 FunctionCallManager::sClientMap_[clientID]->setClientID(clientID); 129 131 } 130 FunctionCallManager:: clientMap_[clientID]->addCallMember(functionID, objectID, &mt1, &mt2, &mt3);132 FunctionCallManager::sClientMap_[clientID]->addCallMember(functionID, objectID, &mt1, &mt2, &mt3); 131 133 } 132 134 void FunctionCallManager::addCallMember(uint32_t functionID, uint32_t objectID, uint32_t clientID, const MultiType& mt1, const MultiType& mt2, const MultiType& mt3, const MultiType& mt4) 133 135 { 134 if( clientMap_.find(clientID)==clientMap_.end())136 if(sClientMap_.find(clientID)==sClientMap_.end()) 135 137 { 136 FunctionCallManager:: clientMap_[clientID] = new packet::FunctionCalls;137 FunctionCallManager:: clientMap_[clientID]->setClientID(clientID);138 FunctionCallManager::sClientMap_[clientID] = new packet::FunctionCalls; 139 FunctionCallManager::sClientMap_[clientID]->setClientID(clientID); 138 140 } 139 FunctionCallManager:: clientMap_[clientID]->addCallMember(functionID, objectID, &mt1, &mt2, &mt3, &mt4);141 FunctionCallManager::sClientMap_[clientID]->addCallMember(functionID, objectID, &mt1, &mt2, &mt3, &mt4); 140 142 } 141 143 void FunctionCallManager::addCallMember(uint32_t functionID, uint32_t objectID, uint32_t clientID, const MultiType& mt1, const MultiType& mt2, const MultiType& mt3, const MultiType& mt4, const MultiType& mt5) 142 144 { 143 if( clientMap_.find(clientID)==clientMap_.end())145 if(sClientMap_.find(clientID)==sClientMap_.end()) 144 146 { 145 FunctionCallManager:: clientMap_[clientID] = new packet::FunctionCalls;146 FunctionCallManager:: clientMap_[clientID]->setClientID(clientID);147 FunctionCallManager::sClientMap_[clientID] = new packet::FunctionCalls; 148 FunctionCallManager::sClientMap_[clientID]->setClientID(clientID); 147 149 } 148 FunctionCallManager:: clientMap_[clientID]->addCallMember(functionID, objectID, &mt1, &mt2, &mt3, &mt4, &mt5);150 FunctionCallManager::sClientMap_[clientID]->addCallMember(functionID, objectID, &mt1, &mt2, &mt3, &mt4, &mt5); 149 151 } 150 152 … … 154 156 { 155 157 std::map<uint32_t, packet::FunctionCalls*>::iterator it; 156 for (it = FunctionCallManager:: clientMap_.begin(); it != FunctionCallManager::clientMap_.end(); it++)158 for (it = FunctionCallManager::sClientMap_.begin(); it != FunctionCallManager::sClientMap_.end(); ++it ) 157 159 { 158 assert(!FunctionCallManager:: clientMap_.empty());160 assert(!FunctionCallManager::sClientMap_.empty()); 159 161 it->second->send(); 160 162 } 161 FunctionCallManager::clientMap_.clear(); 163 FunctionCallManager::sClientMap_.clear(); 164 } 165 166 void FunctionCallManager::bufferIncomingFunctionCall(const orxonox::FunctionCall& fctCall) 167 { 168 if( !GameMode::isMaster() ) 169 FunctionCallManager::sIncomingFunctionCallBuffer_.push_back( fctCall ); 170 } 171 172 void FunctionCallManager::processBufferedFunctionCalls() 173 { 174 std::vector<FunctionCall>::iterator it = FunctionCallManager::sIncomingFunctionCallBuffer_.begin(); 175 while( it!=FunctionCallManager::sIncomingFunctionCallBuffer_.end() ) 176 { 177 if( it->execute() ) 178 FunctionCallManager::sIncomingFunctionCallBuffer_.erase(it); 179 else 180 ++it; 181 } 162 182 } 163 183 -
code/trunk/src/libraries/network/FunctionCallManager.h
r6417 r7495 33 33 34 34 #include <map> 35 #include <vector> 35 36 #include "util/UtilPrereqs.h" 37 #include "FunctionCall.h" 36 38 37 39 namespace orxonox { … … 58 60 59 61 static void sendCalls(); 62 63 static void bufferIncomingFunctionCall( const FunctionCall& fctCall ); 64 static void processBufferedFunctionCalls(); 60 65 61 static std::map<uint32_t, packet::FunctionCalls*> clientMap_; 66 static std::map<uint32_t, packet::FunctionCalls*> sClientMap_; 67 static std::vector<FunctionCall> sIncomingFunctionCallBuffer_; 62 68 protected: 63 69 FunctionCallManager(); -
code/trunk/src/libraries/network/NetworkFunction.h
r7284 r7495 139 139 140 140 // 141 virtual voidcall(uint32_t objectID)=0;142 virtual voidcall(uint32_t objectID, const MultiType& mt1)=0;143 virtual voidcall(uint32_t objectID, const MultiType& mt1, const MultiType& mt2)=0;144 virtual voidcall(uint32_t objectID, const MultiType& mt1, const MultiType& mt2, const MultiType& mt3)=0;145 virtual voidcall(uint32_t objectID, const MultiType& mt1, const MultiType& mt2, const MultiType& mt3, const MultiType& mt4)=0;146 virtual voidcall(uint32_t objectID, const MultiType& mt1, const MultiType& mt2, const MultiType& mt3, const MultiType& mt4, const MultiType& mt5)=0;141 virtual bool call(uint32_t objectID)=0; 142 virtual bool call(uint32_t objectID, const MultiType& mt1)=0; 143 virtual bool call(uint32_t objectID, const MultiType& mt1, const MultiType& mt2)=0; 144 virtual bool call(uint32_t objectID, const MultiType& mt1, const MultiType& mt2, const MultiType& mt3)=0; 145 virtual bool call(uint32_t objectID, const MultiType& mt1, const MultiType& mt2, const MultiType& mt3, const MultiType& mt4)=0; 146 virtual bool call(uint32_t objectID, const MultiType& mt1, const MultiType& mt2, const MultiType& mt3, const MultiType& mt4, const MultiType& mt5)=0; 147 147 148 148 private: … … 156 156 NetworkMemberFunction(const FunctorMemberPtr<T>& functor, const std::string& name, const NetworkFunctionPointer& p); 157 157 158 inline void call(uint32_t objectID) 159 { 160 if ( Synchronisable::getSynchronisable(objectID)!=0 ) 158 inline bool call(uint32_t objectID) 159 { 160 if ( Synchronisable::getSynchronisable(objectID)!=0 ) 161 { 161 162 (*this->functor_)(orxonox_cast<T*>(Synchronisable::getSynchronisable(objectID))); 162 } 163 inline void call(uint32_t objectID, const MultiType& mt1) 164 { 165 if ( Synchronisable::getSynchronisable(objectID)!=0 ) 163 return true; 164 } 165 else 166 return false; 167 } 168 inline bool call(uint32_t objectID, const MultiType& mt1) 169 { 170 if ( Synchronisable::getSynchronisable(objectID)!=0 ) 171 { 166 172 (*this->functor_)(orxonox_cast<T*>(Synchronisable::getSynchronisable(objectID)), mt1); 167 } 168 inline void call(uint32_t objectID, const MultiType& mt1, const MultiType& mt2) 169 { 170 if ( Synchronisable::getSynchronisable(objectID)!=0 ) 173 return true; 174 } 175 else 176 return false; 177 } 178 inline bool call(uint32_t objectID, const MultiType& mt1, const MultiType& mt2) 179 { 180 if ( Synchronisable::getSynchronisable(objectID)!=0 ) 181 { 171 182 (*this->functor_)(orxonox_cast<T*>(Synchronisable::getSynchronisable(objectID)), mt1, mt2); 172 } 173 inline void call(uint32_t objectID, const MultiType& mt1, const MultiType& mt2, const MultiType& mt3) 174 { 175 if ( Synchronisable::getSynchronisable(objectID)!=0 ) 183 return true; 184 } 185 else 186 return false; 187 } 188 inline bool call(uint32_t objectID, const MultiType& mt1, const MultiType& mt2, const MultiType& mt3) 189 { 190 if ( Synchronisable::getSynchronisable(objectID)!=0 ) 191 { 176 192 (*this->functor_)(orxonox_cast<T*>(Synchronisable::getSynchronisable(objectID)), mt1, mt2, mt3); 177 } 178 inline void call(uint32_t objectID, const MultiType& mt1, const MultiType& mt2, const MultiType& mt3, const MultiType& mt4) 179 { 180 if ( Synchronisable::getSynchronisable(objectID)!=0 ) 193 return true; 194 } 195 else 196 return false; 197 } 198 inline bool call(uint32_t objectID, const MultiType& mt1, const MultiType& mt2, const MultiType& mt3, const MultiType& mt4) 199 { 200 if ( Synchronisable::getSynchronisable(objectID)!=0 ) 201 { 181 202 (*this->functor_)(orxonox_cast<T*>(Synchronisable::getSynchronisable(objectID)), mt1, mt2, mt3, mt4); 182 } 183 inline void call(uint32_t objectID, const MultiType& mt1, const MultiType& mt2, const MultiType& mt3, const MultiType& mt4, const MultiType& mt5) 184 { 185 if ( Synchronisable::getSynchronisable(objectID)!=0 ) 203 return true; 204 } 205 else 206 return false; 207 } 208 inline bool call(uint32_t objectID, const MultiType& mt1, const MultiType& mt2, const MultiType& mt3, const MultiType& mt4, const MultiType& mt5) 209 { 210 if ( Synchronisable::getSynchronisable(objectID)!=0 ) 211 { 186 212 (*this->functor_)(orxonox_cast<T*>(Synchronisable::getSynchronisable(objectID)), mt1, mt2, mt3, mt4, mt5); 213 return true; 214 } 215 else 216 return false; 187 217 } 188 218 -
code/trunk/src/libraries/network/packet/FunctionCalls.cc
r7490 r7495 31 31 #include <cassert> 32 32 #include "network/FunctionCall.h" 33 #include "network/FunctionCallManager.h" 33 34 34 35 namespace orxonox { … … 66 67 FunctionCall fctCall; 67 68 fctCall.loadData(temp); 68 fctCall.execute(); 69 if( !fctCall.execute() ) 70 FunctionCallManager::bufferIncomingFunctionCall( fctCall ); 69 71 } 70 72
Note: See TracChangeset
for help on using the changeset viewer.