[Orxonox-commit 322] r2948 - in branches/netp2/src: network orxonox/objects
scheusso at orxonox.net
scheusso at orxonox.net
Fri May 1 23:34:14 CEST 2009
Author: scheusso
Date: 2009-05-01 23:34:14 +0200 (Fri, 01 May 2009)
New Revision: 2948
Modified:
branches/netp2/src/network/Client.cc
branches/netp2/src/network/NetworkFunction.cc
branches/netp2/src/network/NetworkFunction.h
branches/netp2/src/orxonox/objects/Test.cc
branches/netp2/src/orxonox/objects/Test.h
Log:
member function calls should work now
argument transfer still untested
Modified: branches/netp2/src/network/Client.cc
===================================================================
--- branches/netp2/src/network/Client.cc 2009-05-01 20:24:27 UTC (rev 2947)
+++ branches/netp2/src/network/Client.cc 2009-05-01 21:34:14 UTC (rev 2948)
@@ -46,6 +46,7 @@
#include "synchronisable/Synchronisable.h"
#include "core/CoreIncludes.h"
#include "packet/Packet.h"
+#include "FunctionCallManager.h"
// #include "packet/Acknowledgement.h"
@@ -148,6 +149,7 @@
COUT(3) << "Problem adding partial gamestate to queue" << std::endl;
// gs gets automatically deleted by enet callback
}
+ FunctionCallManager::sendCalls();
}
ENetEvent *event;
// stop if the packet queue is empty
Modified: branches/netp2/src/network/NetworkFunction.cc
===================================================================
--- branches/netp2/src/network/NetworkFunction.cc 2009-05-01 20:24:27 UTC (rev 2947)
+++ branches/netp2/src/network/NetworkFunction.cc 2009-05-01 21:34:14 UTC (rev 2948)
@@ -69,6 +69,7 @@
NetworkFunctionStatic::~NetworkFunctionStatic()
{
+ delete this->functor_;
}
Modified: branches/netp2/src/network/NetworkFunction.h
===================================================================
--- branches/netp2/src/network/NetworkFunction.h 2009-05-01 20:24:27 UTC (rev 2947)
+++ branches/netp2/src/network/NetworkFunction.h 2009-05-01 21:34:14 UTC (rev 2948)
@@ -37,6 +37,7 @@
#include <cassert>
#include "util/MultiType.h"
#include "synchronisable/Synchronisable.h"
+#include "OrxonoxConfig.h"
#include "FunctionCallManager.h"
@@ -157,8 +158,11 @@
NetworkMemberFunctionBase(name, p), functor_(functor)
{
}
+template <class T> NetworkMemberFunction<T>::~NetworkMemberFunction()
+{
+ delete this->functor_;
+}
-
template<class T> inline void copyPtr( T ptr, NetworkFunctionPointer& destptr)
{
memset((uint8_t*)&destptr + sizeof(T), 0, sizeof(NetworkFunctionPointer)-sizeof(T));
@@ -172,7 +176,6 @@
{
NetworkFunctionPointer destptr;
copyPtr( ptr, destptr );
- COUT(0) << "-==================== destptr: " << destptr.pointer[0] << ", " << destptr.pointer[1] << endl;
new NetworkFunctionStatic( createFunctor(ptr), name, destptr );
return 0;
}
@@ -181,25 +184,27 @@
{
NetworkFunctionPointer destptr;
copyPtr( ptr, destptr );
- new NetworkMemberFunction<T>( new FunctorMember<T>(ptr), name, destptr );
+ new NetworkMemberFunction<T>( createFunctor(ptr), name, destptr );
return 0;
}
-#define registerStaticNetworkFunction( functionPointer, name ) \
- void* NETWORK_FUNCTION_name##a = registerStaticNetworkFunctionFct( functionPointer, name );
-#define registerMemberNetworkFunction( functionPointer, class, name ) \
- void* NETWORK_FUNCTION_class##name##a = registerMemberNetworkFunction<class>( functionPointer, name );
+#define registerStaticNetworkFunction( functionPointer ) \
+ static void* MACRO_CONCATENATE( NETWORK_FUNCTION_, __LINE__ ) = registerStaticNetworkFunctionFct( functionPointer, #functionPointer );
+#define registerMemberNetworkFunction( class, function ) \
+ static void* MACRO_CONCATENATE( NETWORK_FUNCTION_##class, __LINE__ ) = registerMemberNetworkFunctionFct<class>( &class::function, #class "_" #function);
+ // call it with functionPointer, clientID, args
#define callStaticNetworkFunction( functionPointer, ...) \
{ \
NetworkFunctionPointer p1; \
copyPtr( functionPointer, p1 ); \
FunctionCallManager::addCallStatic(NetworkFunctionStatic::getFunction(p1)->getNetworkID(), __VA_ARGS__); \
}
-#define callMemberNetworkFunction( functionPointer, objectID, ...) \
+ // call it with class, function, objectID, clientID, args
+#define callMemberNetworkFunction( class, function, objectID, ...) \
{ \
NetworkFunctionPointer p1; \
- copyPtr( functionPointer, p1 ); \
- FunctionCallManager::addCallMember(NetworkMemberFunctionBase::getFunction(p1)->getNetworkID(), objectID, __VA_ARGS__) \
+ copyPtr( &class::function, p1 ); \
+ FunctionCallManager::addCallMember(NetworkMemberFunctionBase::getFunction(p1)->getNetworkID(), objectID, __VA_ARGS__); \
}
Modified: branches/netp2/src/orxonox/objects/Test.cc
===================================================================
--- branches/netp2/src/orxonox/objects/Test.cc 2009-05-01 20:24:27 UTC (rev 2947)
+++ branches/netp2/src/orxonox/objects/Test.cc 2009-05-01 21:34:14 UTC (rev 2948)
@@ -48,7 +48,8 @@
//void* NETWORK_FUNCTION_TEST_B = memcpy(&NETWORK_FUNCTION_POINTER, &a, sizeof(a));
// NetworkFunctionBase* NETWORK_FUNCTION_TEST_C = new NetworkFunctionStatic( createFunctor(&Test::printV1), "bla", NETWORK_FUNCTION_POINTER );
- registerStaticNetworkFunction( &Test::printV1, "printV1" );
+ registerStaticNetworkFunction( &Test::printV1 );
+ registerMemberNetworkFunction( Test, checkU1 );
Test* Test::instance_ = 0;
@@ -100,6 +101,13 @@
callStaticNetworkFunction( &Test::printV1, clientID );
}
+ void Test::tick(float dt)
+ {
+ if(!Core::isMaster())
+ callMemberNetworkFunction( Test, checkU1, this->getObjectID(), 0 );
+// callMemberNetworkFunction( &Test::printV1, this->getObjectID(), 0);
+ }
+
void Test::checkU1(){ COUT(1) << "U1 changed: " << u1 << std::endl; }
void Test::checkU2(){ COUT(1) << "U2 changed: " << u2 << std::endl; }
void Test::checkU3(){ COUT(1) << "U3 changed: " << u3 << std::endl; }
Modified: branches/netp2/src/orxonox/objects/Test.h
===================================================================
--- branches/netp2/src/orxonox/objects/Test.h 2009-05-01 20:24:27 UTC (rev 2947)
+++ branches/netp2/src/orxonox/objects/Test.h 2009-05-01 21:34:14 UTC (rev 2948)
@@ -32,6 +32,7 @@
#include "OrxonoxPrereqs.h"
#include "core/BaseObject.h"
#include "network/synchronisable/Synchronisable.h"
+#include "Tickable.h"
typedef int TYPE;
@@ -40,7 +41,7 @@
namespace orxonox
{
- class _OrxonoxExport Test: public BaseObject, public Synchronisable
+ class _OrxonoxExport Test: public BaseObject, public Synchronisable, public Tickable
{
public:
Test(BaseObject* creator);
@@ -50,6 +51,7 @@
void registerVariables();
static void call(unsigned int clientID);
+ virtual void tick(float dt);
//unsigned functions
More information about the Orxonox-commit
mailing list