[Orxonox-commit 5813] r10473 - in code/branches/core7/src/libraries/network: . packet
landauf at orxonox.net
landauf at orxonox.net
Mon May 25 14:04:44 CEST 2015
Author: landauf
Date: 2015-05-25 14:04:43 +0200 (Mon, 25 May 2015)
New Revision: 10473
Modified:
code/branches/core7/src/libraries/network/FunctionCall.cc
code/branches/core7/src/libraries/network/FunctionCall.h
code/branches/core7/src/libraries/network/FunctionCallManager.cc
code/branches/core7/src/libraries/network/FunctionCallManager.h
code/branches/core7/src/libraries/network/NetworkFunctionIncludes.h
code/branches/core7/src/libraries/network/packet/FunctionCalls.cc
code/branches/core7/src/libraries/network/packet/FunctionCalls.h
Log:
bugfix and continuation of the last commit:
- FunctionCall::execute() now returns the correct value (was inverted accidentally)
- FunctionCall::setCall() new calculates the correct callsize (still included the 8bits for isStatic that was removed in the previous commit)
- static and member network functions are now treated equally throughout the whole system (only the macros make a difference)
Modified: code/branches/core7/src/libraries/network/FunctionCall.cc
===================================================================
--- code/branches/core7/src/libraries/network/FunctionCall.cc 2015-05-25 11:51:40 UTC (rev 10472)
+++ code/branches/core7/src/libraries/network/FunctionCall.cc 2015-05-25 12:04:43 UTC (rev 10473)
@@ -51,27 +51,27 @@
switch(this->nrOfArguments_)
{
case 0:
- return !fct->call(this->objectID_);
+ return fct->call(this->objectID_);
case 1:
- return !fct->call(this->objectID_, this->arguments_[0]);
+ return fct->call(this->objectID_, this->arguments_[0]);
case 2:
- return !fct->call(this->objectID_, this->arguments_[0], this->arguments_[1]);
+ return fct->call(this->objectID_, this->arguments_[0], this->arguments_[1]);
case 3:
- return !fct->call(this->objectID_, this->arguments_[0], this->arguments_[1], this->arguments_[2]);
+ return fct->call(this->objectID_, this->arguments_[0], this->arguments_[1], this->arguments_[2]);
case 4:
- return !fct->call(this->objectID_, this->arguments_[0], this->arguments_[1], this->arguments_[2], this->arguments_[3]);
+ return fct->call(this->objectID_, this->arguments_[0], this->arguments_[1], this->arguments_[2], this->arguments_[3]);
case 5:
- return !fct->call(this->objectID_, this->arguments_[0], this->arguments_[1], this->arguments_[2], this->arguments_[3], this->arguments_[4]);
+ return fct->call(this->objectID_, this->arguments_[0], this->arguments_[1], this->arguments_[2], this->arguments_[3], this->arguments_[4]);
default:
assert(0);
return true; // return true to avoid that this functions gets called over and over again
}
}
-void FunctionCall::setCallStatic( uint32_t networkID, const MultiType* mt1, const MultiType* mt2, const MultiType* mt3, const MultiType* mt4, const MultiType* mt5){
+void FunctionCall::setCall( uint32_t networkID, uint32_t objectID, const MultiType* mt1, const MultiType* mt2, const MultiType* mt3, const MultiType* mt4, const MultiType* mt5){
// first determine the size that has to be reserved for this call
- uint32_t callsize = 2*sizeof(uint32_t)+sizeof(uint8_t); //size for network-function-id and nrOfArguments and for bool isStatic
+ uint32_t callsize = 3*sizeof(uint32_t); //size for network-function-id and nrOfArguments and the objectID
uint32_t nrOfArguments = 0;
if(mt1)
{
@@ -104,49 +104,9 @@
}
}
this->nrOfArguments_ = nrOfArguments;
- this->size_ = callsize;
this->functionID_ = networkID;
-}
-
-void FunctionCall::setCallMember( uint32_t networkID, uint32_t objectID, const MultiType* mt1, const MultiType* mt2, const MultiType* mt3, const MultiType* mt4, const MultiType* mt5){
-
- // first determine the size that has to be reserved for this call
- uint32_t callsize = 3*sizeof(uint32_t)+sizeof(uint8_t); //size for network-function-id and nrOfArguments and the objectID and bIsStatic
- uint32_t nrOfArguments = 0;
- if(mt1)
- {
- nrOfArguments++;
- callsize += mt1->getNetworkSize();
- this->arguments_.push_back(*mt1);
- if(mt2)
- {
- nrOfArguments++;
- callsize += mt2->getNetworkSize();
- this->arguments_.push_back(*mt2);
- if(mt3)
- {
- nrOfArguments++;
- callsize += mt3->getNetworkSize();
- this->arguments_.push_back(*mt3);
- if(mt4)
- {
- nrOfArguments++;
- callsize += mt4->getNetworkSize();
- this->arguments_.push_back(*mt4);
- if(mt5)
- {
- nrOfArguments++;
- callsize += mt5->getNetworkSize();
- this->arguments_.push_back(*mt5);
- }
- }
- }
- }
- }
- this->nrOfArguments_ = nrOfArguments;
- this->functionID_ = networkID;
- this->size_ = callsize;
this->objectID_ = objectID;
+ this->size_ = callsize;
}
void FunctionCall::loadData(uint8_t*& mem)
Modified: code/branches/core7/src/libraries/network/FunctionCall.h
===================================================================
--- code/branches/core7/src/libraries/network/FunctionCall.h 2015-05-25 11:51:40 UTC (rev 10472)
+++ code/branches/core7/src/libraries/network/FunctionCall.h 2015-05-25 12:04:43 UTC (rev 10473)
@@ -51,15 +51,14 @@
inline unsigned int getSize() const { return this->size_; }
bool execute();
- 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);
- 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);
+ void setCall( 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);
void saveData( uint8_t*& mem );
void loadData( uint8_t*& mem );
private:
uint32_t nrOfArguments_;
uint32_t functionID_;
- uint32_t objectID_;
+ uint32_t objectID_; // equals OBJECTID_UNKNOWN for static functions
uint32_t size_;
std::vector<MultiType> arguments_;
};
Modified: code/branches/core7/src/libraries/network/FunctionCallManager.cc
===================================================================
--- code/branches/core7/src/libraries/network/FunctionCallManager.cc 2015-05-25 11:51:40 UTC (rev 10472)
+++ code/branches/core7/src/libraries/network/FunctionCallManager.cc 2015-05-25 12:04:43 UTC (rev 10473)
@@ -38,121 +38,62 @@
std::map<uint32_t, packet::FunctionCalls*> FunctionCallManager::sPeerMap_;
std::vector<std::pair<FunctionCall, std::pair<uint32_t, uint32_t> > > FunctionCallManager::sIncomingFunctionCallBuffer_;
-// Static calls
-void FunctionCallManager::addCallStatic(uint32_t functionID, uint32_t peerID)
+void FunctionCallManager::addCall(uint32_t functionID, uint32_t objectID, uint32_t peerID)
{
if(sPeerMap_.find(peerID)==sPeerMap_.end())
{
FunctionCallManager::sPeerMap_[peerID] = new packet::FunctionCalls;
FunctionCallManager::sPeerMap_[peerID]->setPeerID(peerID);
}
- FunctionCallManager::sPeerMap_[peerID]->addCallStatic(functionID);
+ FunctionCallManager::sPeerMap_[peerID]->addCall(functionID, objectID);
}
-void FunctionCallManager::addCallStatic(uint32_t functionID, uint32_t peerID, const MultiType& mt1)
+void FunctionCallManager::addCall(uint32_t functionID, uint32_t objectID, uint32_t peerID, const MultiType& mt1)
{
if(sPeerMap_.find(peerID)==sPeerMap_.end())
{
FunctionCallManager::sPeerMap_[peerID] = new packet::FunctionCalls;
FunctionCallManager::sPeerMap_[peerID]->setPeerID(peerID);
}
- FunctionCallManager:: sPeerMap_[peerID]->addCallStatic(functionID, &mt1);
+ FunctionCallManager::sPeerMap_[peerID]->addCall(functionID, objectID, &mt1);
}
-void FunctionCallManager::addCallStatic(uint32_t functionID, uint32_t peerID, const MultiType& mt1, const MultiType& mt2)
+void FunctionCallManager::addCall(uint32_t functionID, uint32_t objectID, uint32_t peerID, const MultiType& mt1, const MultiType& mt2)
{
if(sPeerMap_.find(peerID)==sPeerMap_.end())
{
FunctionCallManager::sPeerMap_[peerID] = new packet::FunctionCalls;
FunctionCallManager::sPeerMap_[peerID]->setPeerID(peerID);
}
- FunctionCallManager:: sPeerMap_[peerID]->addCallStatic(functionID, &mt1, &mt2);
+ FunctionCallManager::sPeerMap_[peerID]->addCall(functionID, objectID, &mt1, &mt2);
}
-void FunctionCallManager::addCallStatic(uint32_t functionID, uint32_t peerID, const MultiType& mt1, const MultiType& mt2, const MultiType& mt3)
+void FunctionCallManager::addCall(uint32_t functionID, uint32_t objectID, uint32_t peerID, const MultiType& mt1, const MultiType& mt2, const MultiType& mt3)
{
if(sPeerMap_.find(peerID)==sPeerMap_.end())
{
FunctionCallManager::sPeerMap_[peerID] = new packet::FunctionCalls;
FunctionCallManager::sPeerMap_[peerID]->setPeerID(peerID);
}
- FunctionCallManager:: sPeerMap_[peerID]->addCallStatic(functionID, &mt1, &mt2, &mt3);
+ FunctionCallManager::sPeerMap_[peerID]->addCall(functionID, objectID, &mt1, &mt2, &mt3);
}
-void FunctionCallManager::addCallStatic(uint32_t functionID, uint32_t peerID, const MultiType& mt1, const MultiType& mt2, const MultiType& mt3, const MultiType& mt4)
+void FunctionCallManager::addCall(uint32_t functionID, uint32_t objectID, uint32_t peerID, const MultiType& mt1, const MultiType& mt2, const MultiType& mt3, const MultiType& mt4)
{
if(sPeerMap_.find(peerID)==sPeerMap_.end())
{
FunctionCallManager::sPeerMap_[peerID] = new packet::FunctionCalls;
FunctionCallManager::sPeerMap_[peerID]->setPeerID(peerID);
}
- FunctionCallManager:: sPeerMap_[peerID]->addCallStatic(functionID, &mt1, &mt2, &mt3, &mt4);
+ FunctionCallManager::sPeerMap_[peerID]->addCall(functionID, objectID, &mt1, &mt2, &mt3, &mt4);
}
-void FunctionCallManager::addCallStatic(uint32_t functionID, uint32_t peerID, const MultiType& mt1, const MultiType& mt2, const MultiType& mt3, const MultiType& mt4, const MultiType& mt5)
+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)
{
if(sPeerMap_.find(peerID)==sPeerMap_.end())
{
FunctionCallManager::sPeerMap_[peerID] = new packet::FunctionCalls;
FunctionCallManager::sPeerMap_[peerID]->setPeerID(peerID);
}
- FunctionCallManager:: sPeerMap_[peerID]->addCallStatic(functionID, &mt1, &mt2, &mt3, &mt4, &mt5);
+ FunctionCallManager::sPeerMap_[peerID]->addCall(functionID, objectID, &mt1, &mt2, &mt3, &mt4, &mt5);
}
-
-// MemberCalls
-
-void FunctionCallManager::addCallMember(uint32_t functionID, uint32_t objectID, uint32_t peerID)
-{
- if(sPeerMap_.find(peerID)==sPeerMap_.end())
- {
- FunctionCallManager::sPeerMap_[peerID] = new packet::FunctionCalls;
- FunctionCallManager::sPeerMap_[peerID]->setPeerID(peerID);
- }
- FunctionCallManager::sPeerMap_[peerID]->addCallMember(functionID, objectID);
-}
-void FunctionCallManager::addCallMember(uint32_t functionID, uint32_t objectID, uint32_t peerID, const MultiType& mt1)
-{
- if(sPeerMap_.find(peerID)==sPeerMap_.end())
- {
- FunctionCallManager::sPeerMap_[peerID] = new packet::FunctionCalls;
- FunctionCallManager::sPeerMap_[peerID]->setPeerID(peerID);
- }
- FunctionCallManager::sPeerMap_[peerID]->addCallMember(functionID, objectID, &mt1);
-}
-void FunctionCallManager::addCallMember(uint32_t functionID, uint32_t objectID, uint32_t peerID, const MultiType& mt1, const MultiType& mt2)
-{
- if(sPeerMap_.find(peerID)==sPeerMap_.end())
- {
- FunctionCallManager::sPeerMap_[peerID] = new packet::FunctionCalls;
- FunctionCallManager::sPeerMap_[peerID]->setPeerID(peerID);
- }
- FunctionCallManager::sPeerMap_[peerID]->addCallMember(functionID, objectID, &mt1, &mt2);
-}
-void FunctionCallManager::addCallMember(uint32_t functionID, uint32_t objectID, uint32_t peerID, const MultiType& mt1, const MultiType& mt2, const MultiType& mt3)
-{
- if(sPeerMap_.find(peerID)==sPeerMap_.end())
- {
- FunctionCallManager::sPeerMap_[peerID] = new packet::FunctionCalls;
- FunctionCallManager::sPeerMap_[peerID]->setPeerID(peerID);
- }
- FunctionCallManager::sPeerMap_[peerID]->addCallMember(functionID, objectID, &mt1, &mt2, &mt3);
-}
-void FunctionCallManager::addCallMember(uint32_t functionID, uint32_t objectID, uint32_t peerID, const MultiType& mt1, const MultiType& mt2, const MultiType& mt3, const MultiType& mt4)
-{
- if(sPeerMap_.find(peerID)==sPeerMap_.end())
- {
- FunctionCallManager::sPeerMap_[peerID] = new packet::FunctionCalls;
- FunctionCallManager::sPeerMap_[peerID]->setPeerID(peerID);
- }
- FunctionCallManager::sPeerMap_[peerID]->addCallMember(functionID, objectID, &mt1, &mt2, &mt3, &mt4);
-}
-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)
-{
- if(sPeerMap_.find(peerID)==sPeerMap_.end())
- {
- FunctionCallManager::sPeerMap_[peerID] = new packet::FunctionCalls;
- FunctionCallManager::sPeerMap_[peerID]->setPeerID(peerID);
- }
- FunctionCallManager::sPeerMap_[peerID]->addCallMember(functionID, objectID, &mt1, &mt2, &mt3, &mt4, &mt5);
-}
-
// Send calls
void FunctionCallManager::sendCalls(orxonox::Host* host)
Modified: code/branches/core7/src/libraries/network/FunctionCallManager.h
===================================================================
--- code/branches/core7/src/libraries/network/FunctionCallManager.h 2015-05-25 11:51:40 UTC (rev 10472)
+++ code/branches/core7/src/libraries/network/FunctionCallManager.h 2015-05-25 12:04:43 UTC (rev 10473)
@@ -45,20 +45,13 @@
class _NetworkExport FunctionCallManager
{
public:
- static void addCallStatic(uint32_t functionID, uint32_t peerID);
- static void addCallStatic(uint32_t functionID, uint32_t peerID, const MultiType& mt1);
- static void addCallStatic(uint32_t functionID, uint32_t peerID, const MultiType& mt1, const MultiType& mt2);
- static void addCallStatic(uint32_t functionID, uint32_t peerID, const MultiType& mt1, const MultiType& mt2, const MultiType& mt3);
- static void addCallStatic(uint32_t functionID, uint32_t peerID, const MultiType& mt1, const MultiType& mt2, const MultiType& mt3, const MultiType& mt4);
- static void addCallStatic(uint32_t functionID, uint32_t peerID, const MultiType& mt1, const MultiType& mt2, const MultiType& mt3, const MultiType& mt4, const MultiType& mt5);
+ static void addCall(uint32_t functionID, uint32_t objectID, uint32_t peerID);
+ static void addCall(uint32_t functionID, uint32_t objectID, uint32_t peerID, const MultiType& mt1);
+ static void addCall(uint32_t functionID, uint32_t objectID, uint32_t peerID, const MultiType& mt1, const MultiType& mt2);
+ static void addCall(uint32_t functionID, uint32_t objectID, uint32_t peerID, const MultiType& mt1, const MultiType& mt2, const MultiType& mt3);
+ static void addCall(uint32_t functionID, uint32_t objectID, uint32_t peerID, const MultiType& mt1, const MultiType& mt2, const MultiType& mt3, const MultiType& mt4);
+ 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);
- static void addCallMember(uint32_t functionID, uint32_t objectID, uint32_t peerID);
- static void addCallMember(uint32_t functionID, uint32_t objectID, uint32_t peerID, const MultiType& mt1);
- static void addCallMember(uint32_t functionID, uint32_t objectID, uint32_t peerID, const MultiType& mt1, const MultiType& mt2);
- static void addCallMember(uint32_t functionID, uint32_t objectID, uint32_t peerID, const MultiType& mt1, const MultiType& mt2, const MultiType& mt3);
- static void addCallMember(uint32_t functionID, uint32_t objectID, uint32_t peerID, const MultiType& mt1, const MultiType& mt2, const MultiType& mt3, const MultiType& mt4);
- 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);
-
static void sendCalls(orxonox::Host* host);
static void bufferIncomingFunctionCall( const FunctionCall& fctCall, uint32_t minGamestateID, uint32_t peerID );
Modified: code/branches/core7/src/libraries/network/NetworkFunctionIncludes.h
===================================================================
--- code/branches/core7/src/libraries/network/NetworkFunctionIncludes.h 2015-05-25 11:51:40 UTC (rev 10472)
+++ code/branches/core7/src/libraries/network/NetworkFunctionIncludes.h 2015-05-25 12:04:43 UTC (rev 10473)
@@ -50,7 +50,7 @@
{ \
NetworkFunctionPointer p1; \
copyPtr( functionPointer, p1 ); \
- FunctionCallManager::addCallStatic(NetworkFunctionManager::getFunction(p1)->getNetworkID(), __VA_ARGS__); \
+ FunctionCallManager::addCall(NetworkFunctionManager::getFunction(p1)->getNetworkID(), OBJECTID_UNKNOWN, __VA_ARGS__); \
}
// call it with class, function, objectID, clientID, args
@@ -58,7 +58,7 @@
{ \
NetworkFunctionPointer p1; \
copyPtr( &class::function, p1 ); \
- FunctionCallManager::addCallMember(NetworkFunctionManager::getFunction(p1)->getNetworkID(), objectID, __VA_ARGS__); \
+ FunctionCallManager::addCall(NetworkFunctionManager::getFunction(p1)->getNetworkID(), objectID, __VA_ARGS__); \
}
template<class T> inline void* registerStaticNetworkFunctionFct( T ptr, const std::string& name )
Modified: code/branches/core7/src/libraries/network/packet/FunctionCalls.cc
===================================================================
--- code/branches/core7/src/libraries/network/packet/FunctionCalls.cc 2015-05-25 11:51:40 UTC (rev 10472)
+++ code/branches/core7/src/libraries/network/packet/FunctionCalls.cc 2015-05-25 12:04:43 UTC (rev 10473)
@@ -81,24 +81,15 @@
return true;
}
-void FunctionCalls::addCallStatic( uint32_t networkID, const MultiType* mt1, const MultiType* mt2, const MultiType* mt3, const MultiType* mt4, const MultiType* mt5)
+void FunctionCalls::addCall( uint32_t networkID, uint32_t objectID, const MultiType* mt1, const MultiType* mt2, const MultiType* mt3, const MultiType* mt4, const MultiType* mt5)
{
assert(!isDataENetAllocated());
this->functionCalls_.push(orxonox::FunctionCall());
- this->functionCalls_.back().setCallStatic( networkID, mt1, mt2, mt3, mt4, mt5 );
+ this->functionCalls_.back().setCall( networkID, objectID, mt1, mt2, mt3, mt4, mt5 );
this->currentSize_ += this->functionCalls_.back().getSize();
}
-void FunctionCalls::addCallMember( uint32_t networkID, uint32_t objectID, const MultiType* mt1, const MultiType* mt2, const MultiType* mt3, const MultiType* mt4, const MultiType* mt5)
-{
- assert(!isDataENetAllocated());
-
- this->functionCalls_.push(orxonox::FunctionCall());
- this->functionCalls_.back().setCallMember( networkID, objectID, mt1, mt2, mt3, mt4, mt5 );
- this->currentSize_ += this->functionCalls_.back().getSize();
-}
-
bool FunctionCalls::send(orxonox::Host* host)
{
this->minGamestateID_ = host->getCurrentGamestateID();
Modified: code/branches/core7/src/libraries/network/packet/FunctionCalls.h
===================================================================
--- code/branches/core7/src/libraries/network/packet/FunctionCalls.h 2015-05-25 11:51:40 UTC (rev 10472)
+++ code/branches/core7/src/libraries/network/packet/FunctionCalls.h 2015-05-25 12:04:43 UTC (rev 10473)
@@ -55,8 +55,7 @@
{ assert(!this->isDataENetAllocated()); return currentSize_; }
virtual bool process(orxonox::Host* host);
- 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);
- 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);
+ void addCall( 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);
virtual bool send(orxonox::Host* host);
private:
std::queue<orxonox::FunctionCall> functionCalls_;
More information about the Orxonox-commit
mailing list