- Timestamp:
- Dec 21, 2010, 6:09:09 PM (14 years ago)
- Location:
- code/branches/presentation2
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/presentation2
- Property svn:mergeinfo changed
/code/branches/network3 (added) merged: 7333,7336-7337,7344 /code/branches/network4 (added) merged: 7497,7718,7753-7755 /code/branches/network5 (added) merged: 7757-7759,7772-7778,7780-7781
- Property svn:mergeinfo changed
-
code/branches/presentation2/src/libraries/network/FunctionCallManager.cc
r7495 r7788 30 30 #include "packet/FunctionCalls.h" 31 31 #include "core/GameMode.h" 32 #include "GamestateHandler.h" 32 33 33 34 namespace orxonox { 34 35 35 std::map<uint32_t, packet::FunctionCalls*> FunctionCallManager::s ClientMap_;36 std::vector< FunctionCall> FunctionCallManager::sIncomingFunctionCallBuffer_;36 std::map<uint32_t, packet::FunctionCalls*> FunctionCallManager::sPeerMap_; 37 std::vector<std::pair<FunctionCall, std::pair<uint32_t, uint32_t> > > FunctionCallManager::sIncomingFunctionCallBuffer_; 37 38 38 39 // Static calls 39 40 40 void FunctionCallManager::addCallStatic(uint32_t functionID, uint32_t clientID)41 void FunctionCallManager::addCallStatic(uint32_t functionID, uint32_t peerID) 41 42 { 42 if(s ClientMap_.find(clientID)==sClientMap_.end())43 if(sPeerMap_.find(peerID)==sPeerMap_.end()) 43 44 { 44 FunctionCallManager::s ClientMap_[clientID] = new packet::FunctionCalls;45 FunctionCallManager::s ClientMap_[clientID]->setClientID(clientID);45 FunctionCallManager::sPeerMap_[peerID] = new packet::FunctionCalls; 46 FunctionCallManager::sPeerMap_[peerID]->setPeerID(peerID); 46 47 } 47 FunctionCallManager::s ClientMap_[clientID]->addCallStatic(functionID);48 FunctionCallManager::sPeerMap_[peerID]->addCallStatic(functionID); 48 49 } 49 void FunctionCallManager::addCallStatic(uint32_t functionID, uint32_t clientID, const MultiType& mt1)50 void FunctionCallManager::addCallStatic(uint32_t functionID, uint32_t peerID, const MultiType& mt1) 50 51 { 51 if(s ClientMap_.find(clientID)==sClientMap_.end())52 if(sPeerMap_.find(peerID)==sPeerMap_.end()) 52 53 { 53 FunctionCallManager::s ClientMap_[clientID] = new packet::FunctionCalls;54 FunctionCallManager::s ClientMap_[clientID]->setClientID(clientID);54 FunctionCallManager::sPeerMap_[peerID] = new packet::FunctionCalls; 55 FunctionCallManager::sPeerMap_[peerID]->setPeerID(peerID); 55 56 } 56 FunctionCallManager:: s ClientMap_[clientID]->addCallStatic(functionID, &mt1);57 FunctionCallManager:: sPeerMap_[peerID]->addCallStatic(functionID, &mt1); 57 58 } 58 void FunctionCallManager::addCallStatic(uint32_t functionID, uint32_t clientID, const MultiType& mt1, const MultiType& mt2)59 void FunctionCallManager::addCallStatic(uint32_t functionID, uint32_t peerID, const MultiType& mt1, const MultiType& mt2) 59 60 { 60 if(s ClientMap_.find(clientID)==sClientMap_.end())61 if(sPeerMap_.find(peerID)==sPeerMap_.end()) 61 62 { 62 FunctionCallManager::s ClientMap_[clientID] = new packet::FunctionCalls;63 FunctionCallManager::s ClientMap_[clientID]->setClientID(clientID);63 FunctionCallManager::sPeerMap_[peerID] = new packet::FunctionCalls; 64 FunctionCallManager::sPeerMap_[peerID]->setPeerID(peerID); 64 65 } 65 FunctionCallManager:: s ClientMap_[clientID]->addCallStatic(functionID, &mt1, &mt2);66 FunctionCallManager:: sPeerMap_[peerID]->addCallStatic(functionID, &mt1, &mt2); 66 67 } 67 void FunctionCallManager::addCallStatic(uint32_t functionID, uint32_t clientID, const MultiType& mt1, const MultiType& mt2, const MultiType& mt3)68 void FunctionCallManager::addCallStatic(uint32_t functionID, uint32_t peerID, const MultiType& mt1, const MultiType& mt2, const MultiType& mt3) 68 69 { 69 if(s ClientMap_.find(clientID)==sClientMap_.end())70 if(sPeerMap_.find(peerID)==sPeerMap_.end()) 70 71 { 71 FunctionCallManager::s ClientMap_[clientID] = new packet::FunctionCalls;72 FunctionCallManager::s ClientMap_[clientID]->setClientID(clientID);72 FunctionCallManager::sPeerMap_[peerID] = new packet::FunctionCalls; 73 FunctionCallManager::sPeerMap_[peerID]->setPeerID(peerID); 73 74 } 74 FunctionCallManager:: s ClientMap_[clientID]->addCallStatic(functionID, &mt1, &mt2, &mt3);75 FunctionCallManager:: sPeerMap_[peerID]->addCallStatic(functionID, &mt1, &mt2, &mt3); 75 76 } 76 void FunctionCallManager::addCallStatic(uint32_t functionID, uint32_t clientID, const MultiType& mt1, const MultiType& mt2, const MultiType& mt3, const MultiType& mt4)77 void FunctionCallManager::addCallStatic(uint32_t functionID, uint32_t peerID, const MultiType& mt1, const MultiType& mt2, const MultiType& mt3, const MultiType& mt4) 77 78 { 78 if(s ClientMap_.find(clientID)==sClientMap_.end())79 if(sPeerMap_.find(peerID)==sPeerMap_.end()) 79 80 { 80 FunctionCallManager::s ClientMap_[clientID] = new packet::FunctionCalls;81 FunctionCallManager::s ClientMap_[clientID]->setClientID(clientID);81 FunctionCallManager::sPeerMap_[peerID] = new packet::FunctionCalls; 82 FunctionCallManager::sPeerMap_[peerID]->setPeerID(peerID); 82 83 } 83 FunctionCallManager:: s ClientMap_[clientID]->addCallStatic(functionID, &mt1, &mt2, &mt3, &mt4);84 FunctionCallManager:: sPeerMap_[peerID]->addCallStatic(functionID, &mt1, &mt2, &mt3, &mt4); 84 85 } 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)86 void FunctionCallManager::addCallStatic(uint32_t functionID, uint32_t peerID, const MultiType& mt1, const MultiType& mt2, const MultiType& mt3, const MultiType& mt4, const MultiType& mt5) 86 87 { 87 if(s ClientMap_.find(clientID)==sClientMap_.end())88 if(sPeerMap_.find(peerID)==sPeerMap_.end()) 88 89 { 89 FunctionCallManager::s ClientMap_[clientID] = new packet::FunctionCalls;90 FunctionCallManager::s ClientMap_[clientID]->setClientID(clientID);90 FunctionCallManager::sPeerMap_[peerID] = new packet::FunctionCalls; 91 FunctionCallManager::sPeerMap_[peerID]->setPeerID(peerID); 91 92 } 92 FunctionCallManager:: s ClientMap_[clientID]->addCallStatic(functionID, &mt1, &mt2, &mt3, &mt4, &mt5);93 FunctionCallManager:: sPeerMap_[peerID]->addCallStatic(functionID, &mt1, &mt2, &mt3, &mt4, &mt5); 93 94 } 94 95 … … 96 97 // MemberCalls 97 98 98 void FunctionCallManager::addCallMember(uint32_t functionID, uint32_t objectID, uint32_t clientID)99 void FunctionCallManager::addCallMember(uint32_t functionID, uint32_t objectID, uint32_t peerID) 99 100 { 100 if(s ClientMap_.find(clientID)==sClientMap_.end())101 if(sPeerMap_.find(peerID)==sPeerMap_.end()) 101 102 { 102 FunctionCallManager::s ClientMap_[clientID] = new packet::FunctionCalls;103 FunctionCallManager::s ClientMap_[clientID]->setClientID(clientID);103 FunctionCallManager::sPeerMap_[peerID] = new packet::FunctionCalls; 104 FunctionCallManager::sPeerMap_[peerID]->setPeerID(peerID); 104 105 } 105 FunctionCallManager::s ClientMap_[clientID]->addCallMember(functionID, objectID);106 FunctionCallManager::sPeerMap_[peerID]->addCallMember(functionID, objectID); 106 107 } 107 void FunctionCallManager::addCallMember(uint32_t functionID, uint32_t objectID, uint32_t clientID, const MultiType& mt1)108 void FunctionCallManager::addCallMember(uint32_t functionID, uint32_t objectID, uint32_t peerID, const MultiType& mt1) 108 109 { 109 if(s ClientMap_.find(clientID)==sClientMap_.end())110 if(sPeerMap_.find(peerID)==sPeerMap_.end()) 110 111 { 111 FunctionCallManager::s ClientMap_[clientID] = new packet::FunctionCalls;112 FunctionCallManager::s ClientMap_[clientID]->setClientID(clientID);112 FunctionCallManager::sPeerMap_[peerID] = new packet::FunctionCalls; 113 FunctionCallManager::sPeerMap_[peerID]->setPeerID(peerID); 113 114 } 114 FunctionCallManager::s ClientMap_[clientID]->addCallMember(functionID, objectID, &mt1);115 FunctionCallManager::sPeerMap_[peerID]->addCallMember(functionID, objectID, &mt1); 115 116 } 116 void FunctionCallManager::addCallMember(uint32_t functionID, uint32_t objectID, uint32_t clientID, const MultiType& mt1, const MultiType& mt2)117 void FunctionCallManager::addCallMember(uint32_t functionID, uint32_t objectID, uint32_t peerID, const MultiType& mt1, const MultiType& mt2) 117 118 { 118 if(s ClientMap_.find(clientID)==sClientMap_.end())119 if(sPeerMap_.find(peerID)==sPeerMap_.end()) 119 120 { 120 FunctionCallManager::s ClientMap_[clientID] = new packet::FunctionCalls;121 FunctionCallManager::s ClientMap_[clientID]->setClientID(clientID);121 FunctionCallManager::sPeerMap_[peerID] = new packet::FunctionCalls; 122 FunctionCallManager::sPeerMap_[peerID]->setPeerID(peerID); 122 123 } 123 FunctionCallManager::s ClientMap_[clientID]->addCallMember(functionID, objectID, &mt1, &mt2);124 FunctionCallManager::sPeerMap_[peerID]->addCallMember(functionID, objectID, &mt1, &mt2); 124 125 } 125 void FunctionCallManager::addCallMember(uint32_t functionID, uint32_t objectID, uint32_t clientID, const MultiType& mt1, const MultiType& mt2, const MultiType& mt3)126 void FunctionCallManager::addCallMember(uint32_t functionID, uint32_t objectID, uint32_t peerID, const MultiType& mt1, const MultiType& mt2, const MultiType& mt3) 126 127 { 127 if(s ClientMap_.find(clientID)==sClientMap_.end())128 if(sPeerMap_.find(peerID)==sPeerMap_.end()) 128 129 { 129 FunctionCallManager::s ClientMap_[clientID] = new packet::FunctionCalls;130 FunctionCallManager::s ClientMap_[clientID]->setClientID(clientID);130 FunctionCallManager::sPeerMap_[peerID] = new packet::FunctionCalls; 131 FunctionCallManager::sPeerMap_[peerID]->setPeerID(peerID); 131 132 } 132 FunctionCallManager::s ClientMap_[clientID]->addCallMember(functionID, objectID, &mt1, &mt2, &mt3);133 FunctionCallManager::sPeerMap_[peerID]->addCallMember(functionID, objectID, &mt1, &mt2, &mt3); 133 134 } 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)135 void FunctionCallManager::addCallMember(uint32_t functionID, uint32_t objectID, uint32_t peerID, const MultiType& mt1, const MultiType& mt2, const MultiType& mt3, const MultiType& mt4) 135 136 { 136 if(s ClientMap_.find(clientID)==sClientMap_.end())137 if(sPeerMap_.find(peerID)==sPeerMap_.end()) 137 138 { 138 FunctionCallManager::s ClientMap_[clientID] = new packet::FunctionCalls;139 FunctionCallManager::s ClientMap_[clientID]->setClientID(clientID);139 FunctionCallManager::sPeerMap_[peerID] = new packet::FunctionCalls; 140 FunctionCallManager::sPeerMap_[peerID]->setPeerID(peerID); 140 141 } 141 FunctionCallManager::s ClientMap_[clientID]->addCallMember(functionID, objectID, &mt1, &mt2, &mt3, &mt4);142 FunctionCallManager::sPeerMap_[peerID]->addCallMember(functionID, objectID, &mt1, &mt2, &mt3, &mt4); 142 143 } 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)144 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) 144 145 { 145 if(s ClientMap_.find(clientID)==sClientMap_.end())146 if(sPeerMap_.find(peerID)==sPeerMap_.end()) 146 147 { 147 FunctionCallManager::s ClientMap_[clientID] = new packet::FunctionCalls;148 FunctionCallManager::s ClientMap_[clientID]->setClientID(clientID);148 FunctionCallManager::sPeerMap_[peerID] = new packet::FunctionCalls; 149 FunctionCallManager::sPeerMap_[peerID]->setPeerID(peerID); 149 150 } 150 FunctionCallManager::s ClientMap_[clientID]->addCallMember(functionID, objectID, &mt1, &mt2, &mt3, &mt4, &mt5);151 FunctionCallManager::sPeerMap_[peerID]->addCallMember(functionID, objectID, &mt1, &mt2, &mt3, &mt4, &mt5); 151 152 } 152 153 153 154 // Send calls 154 155 155 void FunctionCallManager::sendCalls( )156 void FunctionCallManager::sendCalls(orxonox::Host* host) 156 157 { 157 158 std::map<uint32_t, packet::FunctionCalls*>::iterator it; 158 for (it = FunctionCallManager::s ClientMap_.begin(); it != FunctionCallManager::sClientMap_.end(); ++it )159 for (it = FunctionCallManager::sPeerMap_.begin(); it != FunctionCallManager::sPeerMap_.end(); ++it ) 159 160 { 160 assert(!FunctionCallManager::s ClientMap_.empty());161 it->second->send( );161 assert(!FunctionCallManager::sPeerMap_.empty()); 162 it->second->send(host); 162 163 } 163 FunctionCallManager::s ClientMap_.clear();164 FunctionCallManager::sPeerMap_.clear(); 164 165 } 165 166 166 void FunctionCallManager::bufferIncomingFunctionCall(const orxonox::FunctionCall& fctCall )167 void FunctionCallManager::bufferIncomingFunctionCall(const orxonox::FunctionCall& fctCall, uint32_t minGamestateID, uint32_t peerID) 167 168 { 168 if( !GameMode::isMaster() ) 169 FunctionCallManager::sIncomingFunctionCallBuffer_.push_back( fctCall ); 169 FunctionCallManager::sIncomingFunctionCallBuffer_.push_back( std::make_pair(fctCall, std::make_pair(minGamestateID, peerID))); 170 170 } 171 171 172 172 void FunctionCallManager::processBufferedFunctionCalls() 173 173 { 174 std::vector< FunctionCall>::iterator it = FunctionCallManager::sIncomingFunctionCallBuffer_.begin();174 std::vector<std::pair<FunctionCall, std::pair<uint32_t, uint32_t> > >::iterator it = FunctionCallManager::sIncomingFunctionCallBuffer_.begin(); 175 175 while( it!=FunctionCallManager::sIncomingFunctionCallBuffer_.end() ) 176 176 { 177 if( it-> execute() )177 if( it->first.execute() ) 178 178 FunctionCallManager::sIncomingFunctionCallBuffer_.erase(it); 179 179 else 180 { 180 181 ++it; 182 } 181 183 } 182 184 }
Note: See TracChangeset
for help on using the changeset viewer.