[Orxonox-commit 5906] r10565 - in code/branches/core7/src/libraries/network: . packet
landauf at orxonox.net
landauf at orxonox.net
Sun Aug 30 14:36:28 CEST 2015
Author: landauf
Date: 2015-08-30 14:36:27 +0200 (Sun, 30 Aug 2015)
New Revision: 10565
Modified:
code/branches/core7/src/libraries/network/FunctionCall.cc
code/branches/core7/src/libraries/network/NetworkFunction.cc
code/branches/core7/src/libraries/network/NetworkFunctionManager.cc
code/branches/core7/src/libraries/network/NetworkFunctionManager.h
code/branches/core7/src/libraries/network/packet/FunctionIDs.cc
Log:
fixed mapping of FunctionIDs - same reason like for ClassIDs in r10564
Modified: code/branches/core7/src/libraries/network/FunctionCall.cc
===================================================================
--- code/branches/core7/src/libraries/network/FunctionCall.cc 2015-08-30 11:36:54 UTC (rev 10564)
+++ code/branches/core7/src/libraries/network/FunctionCall.cc 2015-08-30 12:36:27 UTC (rev 10565)
@@ -46,7 +46,8 @@
bool FunctionCall::execute(){
- NetworkFunctionBase* fct = static_cast<NetworkFunctionStatic*>(NetworkFunctionManager::getInstance().getFunctionByNetworkId( this->functionID_ ));
+ NetworkFunctionBase* fct = NetworkFunctionManager::getInstance().getFunctionByNetworkId( this->functionID_ );
+ assert( fct != NULL );
assert( this->nrOfArguments_==this->arguments_.size() );
switch(this->nrOfArguments_)
{
Modified: code/branches/core7/src/libraries/network/NetworkFunction.cc
===================================================================
--- code/branches/core7/src/libraries/network/NetworkFunction.cc 2015-08-30 11:36:54 UTC (rev 10564)
+++ code/branches/core7/src/libraries/network/NetworkFunction.cc 2015-08-30 12:36:27 UTC (rev 10565)
@@ -41,7 +41,6 @@
void NetworkFunctionBase::setNetworkID(uint32_t id)
{
- NetworkFunctionManager::getInstance().unregisterFunction(this); // unregister with old id
this->networkID_ = id;
NetworkFunctionManager::getInstance().registerFunction(this); // register with new id
}
Modified: code/branches/core7/src/libraries/network/NetworkFunctionManager.cc
===================================================================
--- code/branches/core7/src/libraries/network/NetworkFunctionManager.cc 2015-08-30 11:36:54 UTC (rev 10564)
+++ code/branches/core7/src/libraries/network/NetworkFunctionManager.cc 2015-08-30 12:36:27 UTC (rev 10565)
@@ -67,6 +67,17 @@
{
std::map<uint32_t, NetworkFunctionBase*>::iterator it = idMap_.find(id);
assert(it != idMap_.end());
- return it->second;
+ if(it != idMap_.end())
+ return it->second;
+ else
+ return NULL;
}
+
+ /**
+ @brief Cleans the NetworkID map (needed on clients for correct initialization)
+ */
+ void NetworkFunctionManager::clearNetworkIDs()
+ {
+ this->idMap_.clear();
+ }
}
Modified: code/branches/core7/src/libraries/network/NetworkFunctionManager.h
===================================================================
--- code/branches/core7/src/libraries/network/NetworkFunctionManager.h 2015-08-30 11:36:54 UTC (rev 10564)
+++ code/branches/core7/src/libraries/network/NetworkFunctionManager.h 2015-08-30 12:36:27 UTC (rev 10565)
@@ -55,6 +55,8 @@
NetworkFunctionBase* getFunctionByFunctionPointer(const NetworkFunctionPointer& p);
NetworkFunctionBase* getFunctionByNetworkId(uint32_t id);
+ void clearNetworkIDs();
+
private:
std::set<NetworkFunctionBase*> functions_;
std::map<std::string, NetworkFunctionBase*> nameMap_;
Modified: code/branches/core7/src/libraries/network/packet/FunctionIDs.cc
===================================================================
--- code/branches/core7/src/libraries/network/packet/FunctionIDs.cc 2015-08-30 11:36:54 UTC (rev 10564)
+++ code/branches/core7/src/libraries/network/packet/FunctionIDs.cc 2015-08-30 12:36:27 UTC (rev 10565)
@@ -127,6 +127,9 @@
uint32_t stringsize;
unsigned char *functionname;
+ //clear the map of network ids
+ NetworkFunctionManager::getInstance().clearNetworkIDs();
+
orxout(verbose, context::packets) << "=== processing functionids: " << endl;
std::pair<uint32_t, std::string> tempPair;
// read the total number of classes
More information about the Orxonox-commit
mailing list