Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 2245


Ignore:
Timestamp:
Nov 22, 2008, 11:54:48 AM (16 years ago)
Author:
scheusso
Message:

most coding is done, still testing now
types should get transfered in platform independent formats now

Location:
code/branches/network64/src
Files:
2 added
23 edited

Legend:

Unmodified
Added
Removed
  • code/branches/network64/src/network/NetworkPrereqs.h

    r2171 r2245  
    7070  class GamestateManager;
    7171  class GamestateHandler;
     72  class NetworkCallbackBase;
    7273  class PacketBuffer;
    7374  class Server;
    7475  class ServerFrameListener;
    7576  class Synchronisable;
     77  class SynchronisableVariableBase;
     78  template <class T> class SynchronisableVariable;
     79  template <class T> class SynchronisableVariableBidirectional;
    7680  struct ClientList;
    7781  struct PacketEnvelope;
    7882  struct QueueItem;
    7983  struct syncData;
    80   struct synchronisableVariable;
    8184  namespace packet{
    8285    class Gamestate;
  • code/branches/network64/src/network/synchronisable/CMakeLists.txt

    r2211 r2245  
    11SET( SRC_FILES
    22  Synchronisable.cc
     3  SynchronisableVariable.cc
    34)
    45
  • code/branches/network64/src/network/synchronisable/Synchronisable.cc

    r2211 r2245  
    4040
    4141#include "Synchronisable.h"
     42#include "SynchronisableSpecialisations.cc" // this defines all specialisations for registerVariable
    4243
    4344#include <cstring>
     
    7879      objectID=OBJECTID_UNKNOWN;
    7980    classID = (unsigned int)-1;
    80     syncList = new std::list<synchronisableVariable *>;
    8181
    8282
     
    114114    // delete callback function objects
    115115    if(!Identifier::isCreatingHierarchy()){
    116       for(std::list<synchronisableVariable *>::iterator it = syncList->begin(); it!=syncList->end(); it++)
    117         delete (*it)->callback;
     116      for(std::list<SynchronisableVariableBase*>::iterator it = syncList.begin(); it!=syncList.end(); it++)
     117        delete (*it);
    118118      if (this->objectMode_ != 0x0 && (Host::running() && Host::isServer()))
    119119        deletedObjects_.push(objectID);
     
    127127    if (it != objectMap_.end())
    128128      objectMap_.erase(it);
    129   }
    130 
    131   /**
    132    * This function gets called after all neccessary data has been passed to the object
    133    * Overload this function and recall the create function of the parent class
    134    * @return true/false
    135    */
    136   bool Synchronisable::create(){
    137     this->classID = this->getIdentifier()->getNetworkID();
    138 //     COUT(4) << "creating synchronisable: setting classid from " << this->getIdentifier()->getName() << " to: " << classID << std::endl;
    139 
    140 //     COUT(3) << "construct synchronisable +++" << objectID << " | " << classID << std::endl;
    141 //     objectMap_[objectID]=this;
    142 //     assert(objectMap_[objectID]==this);
    143 //     assert(objectMap_[objectID]->objectID==objectID);
    144     return true;
    145129  }
    146130
     
    204188    if (b)
    205189    {
    206         b = no->create();
     190//        b = no->create();
    207191        assert(b);
    208192    }
     
    261245  * @param cb callback object that should get called, if the value of the variable changes
    262246  */
    263   void Synchronisable::registerVariable(void *var, int size, variableType t, uint8_t mode, NetworkCallbackBase *cb){
     247
     248/*  void Synchronisable::registerVariable(void *var, int size, variableType t, uint8_t mode, NetworkCallbackBase *cb){
    264249    assert( mode==direction::toclient || mode==direction::toserver || mode==direction::serverMaster || mode==direction::clientMaster);
    265250    // create temporary synch.Var struct
     
    294279    }
    295280#endif
    296   }
    297 
    298   void Synchronisable::unregisterVariable(void *var){
    299     std::list<synchronisableVariable *>::iterator it = syncList->begin();
    300     while(it!=syncList->end()){
    301       if( (*it)->var == var ){
    302         delete *it;
    303         syncList->erase(it);
    304         return;
    305       }
    306       else
    307         it++;
    308     }
    309     bool unregistered_nonexistent_variable = false;
    310     assert(unregistered_nonexistent_variable); //if we reach this point something went wrong:
    311     // the variable has not been registered before
    312   }
    313 
     281  }*/
     282 
    314283
    315284  /**
     
    343312    assert(this->classID==this->getIdentifier()->getNetworkID());
    344313//     this->classID=this->getIdentifier()->getNetworkID(); // TODO: correct this
    345     std::list<synchronisableVariable *>::iterator i;
     314    std::list<SynchronisableVariableBase*>::iterator i;
    346315    unsigned int size;
    347316    size=getSize(id, mode);
     
    361330    COUT(5) << "Synchronisable getting data from objectID: " << objectID << " classID: " << classID << " length: " << size << std::endl;
    362331    // copy to location
    363     for(i=syncList->begin(); i!=syncList->end(); ++i){
    364       if( ((*i)->mode & mode) == 0 ){
    365         COUT(5) << "not getting data: " << std::endl;
    366         continue;  // this variable should only be received
    367       }
    368 
    369       // =========== start bidirectional stuff =============
    370       // if the variable gets synchronised bidirectional, then add the reference to the bytestream
    371       if( ( (*i)->mode & direction::bidirectional ) == direction::bidirectional )
    372       {
    373         if( ( ((*i)->mode == direction::serverMaster) && (mode == 0x1) ) || \
    374             ( ((*i)->mode == direction::clientMaster) && (mode == 0x2) ) )
    375         {
    376           // MASTER
    377           if((*i)->type==DATA){
    378             if( memcmp((*i)->var,(*i)->varBuffer,(*i)->size) != 0 ) //check whether the variable changed during the last tick
    379             {
    380               ((*i)->varReference)++;   //the variable changed so increase the refnr
    381               memcpy((*i)->varBuffer, (*i)->var, (*i)->size); //set the buffer to the new value
    382             }
    383           }
    384           else //STRING
    385           {
    386             if( *static_cast<std::string*>((*i)->var) != *static_cast<std::string*>((*i)->varBuffer) ) //the string changed
    387             {
    388               ((*i)->varReference)++;   //the variable changed
    389               *static_cast<std::string*>((*i)->varBuffer) = *static_cast<std::string*>((*i)->var);  //now set the buffer to the new value
    390             }
    391           }
    392         }
    393         // copy the reference number to the stream
    394         *(uint8_t*)mem = (*i)->varReference;
    395         mem += sizeof( (*i)->varReference );
    396         tempsize += sizeof( (*i)->varReference );
    397       }
    398       // ================== end bidirectional stuff
    399 
    400       switch((*i)->type){
    401         case DATA:
    402           memcpy( (void *)(mem), (void*)((*i)->var), (*i)->size);
    403           mem += (*i)->size;
    404           tempsize += (*i)->size;
    405           break;
    406         case STRING:
    407           memcpy( (void *)(mem), (void *)&((*i)->size), sizeof(size_t) );
    408           mem += sizeof(size_t);
    409           const char *data = ( ( *(std::string *) (*i)->var).c_str());
    410           memcpy( mem, (void*)data, (*i)->size);
    411           COUT(5) << "synchronisable: char: " << (const char *)(mem) << " data: " << data << " string: " << *(std::string *)((*i)->var) << std::endl;
    412           mem += (*i)->size;
    413           tempsize += (*i)->size + sizeof(size_t);
    414           break;
    415       }
     332    for(i=syncList.begin(); i!=syncList.end(); ++i){
     333      (*i)->getData( mem, mode );
     334      tempsize += (*i)->getSize( mode );
    416335    }
    417336    assert(tempsize==size);
     
    429348    if(mode==0x0)
    430349      mode=state_;
    431     std::list<synchronisableVariable *>::iterator i;
     350    std::list<SynchronisableVariableBase *>::iterator i;
    432351    //assert(objectMode_!=0x0);
    433352    //assert( (mode ^ objectMode_) != 0);
    434     if(syncList->empty()){
     353    if(syncList.empty()){
    435354      COUT(4) << "Synchronisable::updateData syncList is empty" << std::endl;
    436355      return false;
    437356    }
    438357
    439     uint8_t *data=mem;
     358    uint8_t* data=mem;
    440359    // start extract header
    441360    synchronisableHeader *syncHeader = (synchronisableHeader *)mem;
     
    452371
    453372    COUT(5) << "Synchronisable: objectID " << syncHeader->objectID << ", classID " << syncHeader->classID << " size: " << syncHeader->size << " synchronising data" << std::endl;
    454     for(i=syncList->begin(); i!=syncList->end() && mem <= data+syncHeader->size; i++){
    455       if( ((*i)->mode ^ mode) == 0 ){
    456         COUT(5) << "synchronisable: not updating variable " << std::endl;
    457         // if we have a forcecallback then do the callback
    458         continue;  // this variable should only be set
    459       }
    460       COUT(5) << "Synchronisable: element size: " << (*i)->size << " type: " << (*i)->type << std::endl;
    461       bool callback=false;
    462       bool master=false;
    463 
    464       if( ( (*i)->mode & direction::bidirectional ) == direction::bidirectional )
    465       {
    466         uint8_t refNr = *(uint8_t *)mem;
    467         if( ( ((*i)->mode == direction::serverMaster) && (mode == 0x1) ) || \
    468             ( ((*i)->mode == direction::clientMaster) && (mode == 0x2) ) )
    469         { // MASTER
    470           master=true;
    471           if( refNr != (*i)->varReference || ( memcmp((*i)->var, (*i)->varBuffer, (*i)->size) != 0 ) )
    472           { // DISCARD data
    473             if( (*i)->type == DATA )
    474             {
    475               mem += sizeof((*i)->varReference) + (*i)->size;
    476             }
    477             else //STRING
    478             {
    479               mem += sizeof(size_t) + *(size_t *)mem;
    480             }
    481             if( forceCallback && (*i)->callback)
    482               (*i)->callback->call();
    483             continue;
    484           }//otherwise everything is ok and we update the value
    485         }
    486         else // SLAVE
    487         {
    488           if( (*i)->varReference == refNr ){
    489             //discard data because it's outdated or not different to what we've got
    490             if( (*i)->type == DATA )
    491             {
    492               mem += sizeof((*i)->varReference) + (*i)->size;
    493             }
    494             else //STRING
    495             {
    496               mem += sizeof(size_t) + *(size_t *)mem;
    497             }
    498             if( forceCallback && (*i)->callback)
    499               (*i)->callback->call();
    500             continue;
    501           }
    502           else
    503             (*i)->varReference = refNr; //copy the reference value for this variable
    504         }
    505         mem += sizeof((*i)->varReference);
    506       }
    507 
    508       switch((*i)->type){
    509         case DATA:
    510           if((*i)->callback) // check whether this variable changed (but only if callback was set)
    511           {
    512             if(memcmp((*i)->var, mem, (*i)->size) != 0)
    513               callback=true;
    514           }
    515           if( master )
    516           {
    517             if( callback || memcmp((*i)->var, mem, (*i)->size) != 0 )
    518               //value changed, so set the buffer to the new value
    519               memcpy((*i)->varBuffer, mem, (*i)->size);
    520           }
    521           memcpy((*i)->var, mem, (*i)->size);
    522           mem += (*i)->size;
    523           break;
    524         case STRING:
    525           (*i)->size = *(size_t *)mem;
    526           mem += sizeof(size_t);
    527 
    528           if( (*i)->callback) // check whether this string changed
    529             if( *static_cast<std::string*>((*i)->var) != std::string((char *)mem) )
    530               callback=true;
    531           if( master )
    532           {
    533             if( callback || *static_cast<std::string*>((*i)->var) != std::string((char *)mem) )
    534               //string changed. set the buffer to the new one
    535               *static_cast<std::string*>((*i)->varBuffer)=*static_cast<std::string*>( (void*)(mem+sizeof(size_t)) );
    536           }
    537 
    538           *((std::string *)((*i)->var)) = std::string((const char*)mem);
    539           COUT(5) << "synchronisable: char: " << (const char*)mem << " string: " << std::string((const char*)mem) << std::endl;
    540           mem += (*i)->size;
    541           break;
    542       }
    543       // call the callback function, if defined
    544       if((callback || forceCallback) && (*i)->callback)
    545         (*i)->callback->call();
     373    for(i=syncList.begin(); i!=syncList.end() && mem <= data+syncHeader->size; i++)
     374    {
     375      (*i)->putData( mem, mode, forceCallback );
    546376    }
    547377    assert(mem == data+syncHeader->size);
     
    561391    if(!doSync(id, mode))
    562392      return 0;
    563     std::list<synchronisableVariable *>::iterator i;
    564     for(i=syncList->begin(); i!=syncList->end(); i++){
    565       if( ((*i)->mode & mode) == 0 )
    566         continue;  // this variable should only be received, so dont add its size to the send-size
    567       switch((*i)->type){
    568       case DATA:
    569         tsize+=(*i)->size;
    570         break;
    571       case STRING:
    572         tsize+=sizeof(int);
    573         (*i)->size=((std::string *)(*i)->var)->length()+1;
    574         COUT(5) << "String size: " << (*i)->size << std::endl;
    575         tsize+=(*i)->size;
    576         break;
    577       }
    578       if( ( (*i)->mode & direction::bidirectional ) == direction::bidirectional )
    579       {
    580         tsize+=sizeof( (*i)->varReference );
    581       }
     393    std::list<SynchronisableVariableBase*>::iterator i;
     394    for(i=syncList.begin(); i!=syncList.end(); i++){
     395      tsize += (*i)->getSize( mode );
    582396    }
    583397    return tsize;
     
    592406    if(mode==0x0)
    593407      mode=state_;
    594     return ( (objectMode_&mode)!=0 && (!syncList->empty() ) );
     408    return ( (objectMode_&mode)!=0 && (!syncList.empty() ) );
    595409  }
    596410
     
    623437    objectMode_=mode;
    624438  }
    625 
     439 
    626440
    627441}
  • code/branches/network64/src/network/synchronisable/Synchronisable.h

    r2211 r2245  
    3535#include <map>
    3636#include <queue>
    37 #include "util/Integers.h"
     37#include <cassert>
     38#include "util/Math.h"
     39#include "util/mbool.h"
    3840#include "core/OrxonoxClass.h"
    39 #include "core/XMLIncludes.h"
     41// TODO: this has to be removed
     42// #include <OgreLight.h>
     43// #include "OrxonoxPrereqs.h"
     44// ============================
    4045#include "NetworkCallback.h"
    41 #include "util/Integers.h"
     46#include "SynchronisableVariable.h"
    4247
    43 #define REGISTERDATA(varname, ...) \
     48/*#define REGISTERDATA(varname, ...) \
    4449    registerVariable((void*)&varname, sizeof(varname), DATA, __VA_ARGS__)
    4550#define REGISTERSTRING(stringname, ...) \
    46     registerVariable(&stringname, stringname.length()+1, STRING, __VA_ARGS__)
     51    registerVariable(&stringname, stringname.length()+1, STRING, __VA_ARGS__)*/
    4752
    4853namespace orxonox
     
    5055  static const unsigned int OBJECTID_UNKNOWN = (unsigned int)-1;
    5156
    52   namespace direction{
    53     enum syncdirection{
     57  namespace objectDirection{
     58    enum objectdirection{
    5459      toclient=0x1,
    5560      toserver=0x2,
    56       bidirectional=0x3,
    57       serverMaster=0x3,
    58       clientMaster=0x7
     61      bidirectional=0x3
    5962    };
    6063  }
    61 
    62   namespace syncmode{
    63     enum mode{
    64       once=0,
    65       always=1
    66     };
    67   }
    68 
    69   enum variableType{
    70     DATA,
    71     STRING,
    72   };
    7364
    7465  struct _NetworkExport synchronisableHeader{
     
    8071  };
    8172
    82   struct _NetworkExport synchronisableVariable{
    83     size_t size;
    84     uint8_t mode; // this determines in which direction the variable gets synchronised
    85     void *var;
    86     variableType type;
    87     NetworkCallbackBase *callback;
    88     void *varBuffer;
    89     uint8_t varReference;
    90   };
    9173
    9274  /**
     
    10183    virtual ~Synchronisable();
    10284
    103 
    104     virtual bool create();
    10585    static void setClient(bool b);
    10686
     
    11595  protected:
    11696    Synchronisable(BaseObject* creator);
    117     void registerVariable(void *var, int size, variableType t, uint8_t mode=0x1, NetworkCallbackBase *cb=0);
    118     void unregisterVariable(void *var);
     97//     void registerVariable(void *var, int size, variableType t, uint8_t mode=0x1, NetworkCallbackBase *cb=0);
     98    template <class T> void registerVariable(T& variable, uint8_t mode=0x1, NetworkCallbackBase *cb=0, bool bidirectional=false);
     99    template <class T> void unregisterVariable(T& var);
    119100    void setObjectMode(uint8_t mode);
    120101    void setObjectFrequency(unsigned int freq){ objectFrequency_ = freq; }
     
    133114    unsigned int classID;
    134115
    135     std::list<synchronisableVariable *> *syncList;
     116    std::list<SynchronisableVariableBase*> syncList;
    136117    static uint8_t state_; // detemines wheter we are server (default) or client
    137118    bool backsync_; // if true the variables with mode > 1 will be synchronised to server (client -> server)
     
    141122    static std::queue<unsigned int> deletedObjects_;
    142123  };
     124 
     125  template <class T> void Synchronisable::registerVariable(T& variable, uint8_t mode, NetworkCallbackBase *cb, bool bidirectional)
     126  {
     127    if (bidirectional)
     128      syncList.push_back(new SynchronisableVariableBidirectional<const T>(variable, mode, cb));
     129    else
     130      syncList.push_back(new SynchronisableVariable<const T>(variable, mode, cb));
     131  }
     132
     133  template <class T> void Synchronisable::unregisterVariable(T& var){
     134    std::list<SynchronisableVariableBase*>::iterator it = syncList.begin();
     135    while(it!=syncList.end()){
     136      if( ((*it)->getReference()) == &var ){
     137        delete (*it);
     138        syncList.erase(it);
     139        return;
     140      }
     141      else
     142        it++;
     143    }
     144    bool unregistered_nonexistent_variable = false;
     145    assert(unregistered_nonexistent_variable); //if we reach this point something went wrong:
     146    // the variable has not been registered before
     147  }
     148 
     149  // ================= Specialisation declarations
     150  template <> void Synchronisable::registerVariable( const ColourValue& variable, uint8_t mode, NetworkCallbackBase* cb, bool bidirectional);template <> void Synchronisable::registerVariable( const ColourValue& variable, uint8_t mode, NetworkCallbackBase* cb, bool bidirectional);
     151  template <> void Synchronisable::registerVariable( ColourValue& variable, uint8_t mode, NetworkCallbackBase* cb, bool bidirectional);
     152  template <> void Synchronisable::registerVariable( const Vector2& variable, uint8_t mode, NetworkCallbackBase* cb, bool bidirectional);
     153  template <> void Synchronisable::registerVariable( Vector2& variable, uint8_t mode, NetworkCallbackBase* cb, bool bidirectional);
     154  template <> void Synchronisable::registerVariable( const Vector3& variable, uint8_t mode, NetworkCallbackBase* cb, bool bidirectional);
     155  template <> void Synchronisable::registerVariable( Vector3& variable, uint8_t mode, NetworkCallbackBase* cb, bool bidirectional);
     156  template <> void Synchronisable::registerVariable( const Vector4& variable, uint8_t mode, NetworkCallbackBase* cb, bool bidirectional);
     157  template <> void Synchronisable::registerVariable( Vector4& variable, uint8_t mode, NetworkCallbackBase* cb, bool bidirectional);
     158  template <> void Synchronisable::registerVariable( mbool& variable, uint8_t mode, NetworkCallbackBase* cb, bool bidirectional);
     159  template <> void Synchronisable::registerVariable( const Quaternion& variable, uint8_t mode, NetworkCallbackBase* cb, bool bidirectional);
     160  template <> void Synchronisable::registerVariable( Quaternion& variable, uint8_t mode, NetworkCallbackBase* cb, bool bidirectional);
     161//   template <> void Synchronisable::registerVariable( LODParticle::LOD& variable, uint8_t mode, NetworkCallbackBase* cb, bool bidirectional);
     162//   template <> void Synchronisable::registerVariable( Ogre::Light::LightTypes& variable, uint8_t mode, NetworkCallbackBase* cb, bool bidirectional);
    143163}
    144164
  • code/branches/network64/src/orxonox/OrxonoxStableHeaders.h

    r2211 r2245  
    1 /*
    2  *   ORXONOX - the hottest 3D action shooter ever to exist
    3  *                    > www.orxonox.net <
    4  *
    5  *
    6  *   License notice:
    7  *
    8  *   This program is free software; you can redistribute it and/or
    9  *   modify it under the terms of the GNU General Public License
    10  *   as published by the Free Software Foundation; either version 2
    11  *   of the License, or (at your option) any later version.
    12  *
    13  *   This program is distributed in the hope that it will be useful,
    14  *   but WITHOUT ANY WARRANTY; without even the implied warranty of
    15  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    16  *   GNU General Public License for more details.
    17  *
    18  *   You should have received a copy of the GNU General Public License
    19  *   along with this program; if not, write to the Free Software
    20  *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
    21  *
    22  *   Author:
    23  *      Reto Grieder
    24  *   Co-authors:
    25  *      ...
    26  *
    27  */
    28 
    29 /**
    30  @file
    31  @brief Contains the frequently used header files of our own writing
    32  */
    33 
    34 #ifndef _OrxonoxStableHeaders_H__
    35 #define _OrxonoxStableHeaders_H__
    36 
    37 #include "util/OrxonoxPlatform.h"
    38 
    39 #if defined(ORXONOX_ENABLE_PCH)
    40 
    41 // including std headers here is useless since they're already precompiled
    42 
    43 #ifndef WIN32_LEAN_AND_MEAN
    44 // prevent Ogre from including winsock.h that messes with winsock2.h from enet
    45 #  define WIN32_LEAN_AND_MEAN
    46 #endif
    47 #include <Ogre.h>
    48 #include <CEGUI.h>
    49 #include "ois/OIS.h"
    50 #include <boost/thread/recursive_mutex.hpp>
    51 //#include <boost/thread/mutex.hpp>
    52 //#include <boost/thread/condition.hpp>
    53 //#include <boost/thread/thread.hpp>
    54 #include <boost/static_assert.hpp>
    55 #include "tinyxml/ticpp.h"
    56 #include "tinyxml/tinyxml.h"
    57 #include "tolua/tolua++.h"
    58 
    59 //Get around Windows hackery (windows.h is included by Ogre.h)
    60 #if ORXONOX_PLATFORM == ORXONOX_PLATFORM_WIN32
    61 #  ifdef max
    62 #    undef max
    63 #  endif
    64 #  ifdef min
    65 #    undef min
    66 #  endif
    67 #endif
    68 
    69 //----------- Our files ----------
    70 //--------------------------------
    71 //// only include when not debugging so that we may find issues with missing headers quicker
    72 //#if defined(NDEBUG)
    73 
    74 #include "util/Convert.h"
    75 #include "util/Debug.h"
    76 #include "util/Exception.h"
    77 #include "util/Math.h"
    78 #include "util/Multitype.h"
    79 #include "util/Sleep.h"
    80 #include "util/String.h"
    81 #include "util/SubString.h"
    82 
    83 #include "core/BaseObject.h"
    84 #include "core/ConsoleCommand.h"
    85 #include "core/CoreIncludes.h"
    86 #include "core/ConfigValueIncludes.h"
    87 #include "core/CommandExecutor.h"
    88 #include "core/Core.h"
    89 #include "core/Executor.h"
    90 #include "core/ObjectList.h"
    91 #include "core/Super.h"
    92 #include "core/XMLIncludes.h"
    93 #include "core/XMLPort.h"
    94 #include "core/input/SimpleInputState.h"
    95 #include "core/input/InputManager.h"
    96 
    97 #include "network/synchronisable/Synchronisable.h"
    98 
    99 #include "Settings.h"
    100 
    101 //#endif /* ifdef NDEBUG */
    102 
    103 #endif /* ORXONOX_COMPILER == ORXONOX_COMPILER_MSVC && !defined(ORXONOX_DISABLE_PCH) */
    104 
    105 #endif /* _OrxonoxStableHeaders_H__ */
  • code/branches/network64/src/orxonox/objects/Level.cc

    r2171 r2245  
    8383    void Level::registerVariables()
    8484    {
    85         REGISTERSTRING(this->xmlfilename_, direction::toclient, new NetworkCallback<Level>(this, &Level::networkcallback_applyXMLFile));
    86         REGISTERSTRING(this->name_,        direction::toclient, new NetworkCallback<Level>(this, &Level::changedName));
    87         REGISTERSTRING(this->description_, direction::toclient);
     85        registerVariable(this->xmlfilename_, variableDirection::toclient, new NetworkCallback<Level>(this, &Level::networkcallback_applyXMLFile));
     86        registerVariable(this->name_,        variableDirection::toclient, new NetworkCallback<Level>(this, &Level::changedName));
     87        registerVariable(this->description_, variableDirection::toclient);
    8888    }
    8989
  • code/branches/network64/src/orxonox/objects/Scene.cc

    r2171 r2245  
    114114    void Scene::registerVariables()
    115115    {
    116         REGISTERSTRING(this->skybox_,     direction::toclient, new NetworkCallback<Scene>(this, &Scene::networkcallback_applySkybox));
    117         REGISTERDATA(this->ambientLight_, direction::toclient, new NetworkCallback<Scene>(this, &Scene::networkcallback_applyAmbientLight));
     116        registerVariable(this->skybox_,     variableDirection::toclient, new NetworkCallback<Scene>(this, &Scene::networkcallback_applySkybox));
     117        registerVariable(this->ambientLight_, variableDirection::toclient, new NetworkCallback<Scene>(this, &Scene::networkcallback_applyAmbientLight));
    118118    }
    119119
  • code/branches/network64/src/orxonox/objects/Test.cc

    r2171 r2245  
    7070        void Test::registerVariables()
    7171        {
    72                 REGISTERDATA ( v1,direction::toclient, new NetworkCallback<Test> ( this, &Test::checkV1 ) );
    73     REGISTERDATA ( v2,direction::toserver, new NetworkCallback<Test> ( this, &Test::checkV2 ) );
    74                 REGISTERDATA ( v3,direction::serverMaster, new NetworkCallback<Test> ( this, &Test::checkV3 ) );
    75     REGISTERDATA ( v4,direction::clientMaster, new NetworkCallback<Test> ( this, &Test::checkV4 ) );
     72                registerVariable ( v1, variableDirection::toclient, new NetworkCallback<Test> ( this, &Test::checkV1 ));
     73    registerVariable ( v2, variableDirection::toserver, new NetworkCallback<Test> ( this, &Test::checkV2 ));
     74                registerVariable ( v3, variableDirection::serverMaster, new NetworkCallback<Test> ( this, &Test::checkV3 ), true );
     75    registerVariable ( v4, variableDirection::clientMaster, new NetworkCallback<Test> ( this, &Test::checkV4 ), true );
    7676        }
    7777
  • code/branches/network64/src/orxonox/objects/Test.h

    r2211 r2245  
    5555      void checkV4();
    5656     
    57       void printV1(){ instance_->checkV1(); }
    58       void printV2(){ instance_->checkV2(); }
    59       void printV3(){ instance_->checkV3(); }
    60       void printV4(){ instance_->checkV4(); }
     57      static void printV1(){ instance_->checkV1(); }
     58      static void printV2(){ instance_->checkV2(); }
     59      static void printV3(){ instance_->checkV3(); }
     60      static void printV4(){ instance_->checkV4(); }
    6161
    6262    private:
  • code/branches/network64/src/orxonox/objects/infos/HumanPlayer.cc

    r2171 r2245  
    6767    void HumanPlayer::registerVariables()
    6868    {
    69         REGISTERSTRING(this->synchronize_nick_, direction::toserver, new NetworkCallback<HumanPlayer>(this, &HumanPlayer::networkcallback_changednick));
     69        registerVariable(this->synchronize_nick_, variableDirection::toserver, new NetworkCallback<HumanPlayer>(this, &HumanPlayer::networkcallback_changednick));
    7070
    71         REGISTERDATA(this->clientID_,     direction::toclient, new NetworkCallback<HumanPlayer>(this, &HumanPlayer::networkcallback_clientIDchanged));
    72         REGISTERDATA(this->server_initialized_, direction::toclient, new NetworkCallback<HumanPlayer>(this, &HumanPlayer::networkcallback_server_initialized));
    73         REGISTERDATA(this->client_initialized_, direction::toserver, new NetworkCallback<HumanPlayer>(this, &HumanPlayer::networkcallback_client_initialized));
     71        registerVariable(this->clientID_,     variableDirection::toclient, new NetworkCallback<HumanPlayer>(this, &HumanPlayer::networkcallback_clientIDchanged));
     72        registerVariable(this->server_initialized_, variableDirection::toclient, new NetworkCallback<HumanPlayer>(this, &HumanPlayer::networkcallback_server_initialized));
     73        registerVariable(this->client_initialized_, variableDirection::toserver, new NetworkCallback<HumanPlayer>(this, &HumanPlayer::networkcallback_client_initialized));
    7474    }
    7575
     
    9999
    100100            if (!Core::isMaster())
    101                 this->setObjectMode(direction::bidirectional);
     101                this->setObjectMode(objectDirection::bidirectional);
    102102            else
    103103                this->setName(this->nick_);
  • code/branches/network64/src/orxonox/objects/infos/PlayerInfo.cc

    r2171 r2245  
    6969    void PlayerInfo::registerVariables()
    7070    {
    71         REGISTERSTRING(this->name_,                 direction::toclient, new NetworkCallback<PlayerInfo>(this, &PlayerInfo::changedName));
    72         REGISTERDATA  (this->controllableEntityID_, direction::toclient, new NetworkCallback<PlayerInfo>(this, &PlayerInfo::networkcallback_changedcontrollableentityID));
    73         REGISTERDATA  (this->bReadyToSpawn_,        direction::toserver);
     71        registerVariable(this->name_,                 variableDirection::toclient, new NetworkCallback<PlayerInfo>(this, &PlayerInfo::changedName));
     72        registerVariable(this->controllableEntityID_, variableDirection::toclient, new NetworkCallback<PlayerInfo>(this, &PlayerInfo::networkcallback_changedcontrollableentityID));
     73        registerVariable(this->bReadyToSpawn_,        variableDirection::toserver);
    7474    }
    7575
  • code/branches/network64/src/orxonox/objects/worldentities/Billboard.cc

    r2171 r2245  
    6464    void Billboard::registerVariables()
    6565    {
    66         REGISTERSTRING(this->material_, direction::toclient, new NetworkCallback<Billboard>(this, &Billboard::changedMaterial));
    67         REGISTERDATA  (this->colour_,   direction::toclient, new NetworkCallback<Billboard>(this, &Billboard::changedColour));
     66        registerVariable(this->material_, variableDirection::toclient, new NetworkCallback<Billboard>(this, &Billboard::changedMaterial));
     67        registerVariable(this->colour_,   variableDirection::toclient, new NetworkCallback<Billboard>(this, &Billboard::changedColour));
    6868    }
    6969
  • code/branches/network64/src/orxonox/objects/worldentities/ControllableEntity.cc

    r2171 r2245  
    165165                this->client_overwrite_ = this->server_overwrite_;
    166166COUT(0) << "CE: bidirectional synchronization" << std::endl;
    167                 this->setObjectMode(direction::bidirectional);
     167                this->setObjectMode(objectDirection::bidirectional);
    168168            }
    169169        }
     
    178178        this->playerID_ = OBJECTID_UNKNOWN;
    179179        this->bControlled_ = false;
    180         this->setObjectMode(direction::toclient);
     180        this->setObjectMode(objectDirection::toclient);
    181181
    182182        if (this->bDestroyWhenPlayerLeft_)
     
    248248    void ControllableEntity::registerVariables()
    249249    {
    250         REGISTERSTRING(this->cameraPositionTemplate_, direction::toclient);
    251 
    252         REGISTERDATA(this->client_overwrite_,   direction::toserver);
    253        
    254         REGISTERDATA(this->server_position_,    direction::toclient, new NetworkCallback<ControllableEntity>(this, &ControllableEntity::processServerPosition));
    255         REGISTERDATA(this->server_velocity_,    direction::toclient, new NetworkCallback<ControllableEntity>(this, &ControllableEntity::processServerVelocity));
    256         REGISTERDATA(this->server_orientation_, direction::toclient, new NetworkCallback<ControllableEntity>(this, &ControllableEntity::processServerOrientation));
    257         REGISTERDATA(this->server_overwrite_,   direction::toclient, new NetworkCallback<ControllableEntity>(this, &ControllableEntity::processOverwrite));
    258 
    259         REGISTERDATA(this->client_position_,    direction::toserver, new NetworkCallback<ControllableEntity>(this, &ControllableEntity::processClientPosition));
    260         REGISTERDATA(this->client_velocity_,    direction::toserver, new NetworkCallback<ControllableEntity>(this, &ControllableEntity::processClientVelocity));
    261         REGISTERDATA(this->client_orientation_, direction::toserver, new NetworkCallback<ControllableEntity>(this, &ControllableEntity::processClientOrientation));
    262 
    263 
    264         REGISTERDATA(this->playerID_, direction::toclient, new NetworkCallback<ControllableEntity>(this, &ControllableEntity::networkcallback_changedplayerID));
     250        registerVariable(this->cameraPositionTemplate_, variableDirection::toclient);
     251 
     252        registerVariable(this->client_overwrite_,   variableDirection::toserver);
     253         
     254        registerVariable(this->server_position_,    variableDirection::toclient, new NetworkCallback<ControllableEntity>(this, &ControllableEntity::processServerPosition));
     255        registerVariable(this->server_velocity_,    variableDirection::toclient, new NetworkCallback<ControllableEntity>(this, &ControllableEntity::processServerVelocity));
     256        registerVariable(this->server_orientation_, variableDirection::toclient, new NetworkCallback<ControllableEntity>(this, &ControllableEntity::processServerOrientation));
     257        registerVariable(this->server_overwrite_,   variableDirection::toclient, new NetworkCallback<ControllableEntity>(this, &ControllableEntity::processOverwrite));
     258 
     259        registerVariable(this->client_position_,    variableDirection::toserver, new NetworkCallback<ControllableEntity>(this, &ControllableEntity::processClientPosition));
     260        registerVariable(this->client_velocity_,    variableDirection::toserver, new NetworkCallback<ControllableEntity>(this, &ControllableEntity::processClientVelocity));
     261        registerVariable(this->client_orientation_, variableDirection::toserver, new NetworkCallback<ControllableEntity>(this, &ControllableEntity::processClientOrientation));
     262 
     263 
     264        registerVariable(this->playerID_, variableDirection::toclient, new NetworkCallback<ControllableEntity>(this, &ControllableEntity::networkcallback_changedplayerID));
    265265    }
    266266
  • code/branches/network64/src/orxonox/objects/worldentities/Light.cc

    r2171 r2245  
    7979    void Light::registerVariables()
    8080    {
    81         REGISTERDATA(this->type_, direction::toclient, new NetworkCallback<Light>(this, &Light::changedType));
    82         REGISTERDATA(this->light_->getDiffuseColour(), direction::toclient);
    83         REGISTERDATA(this->light_->getSpecularColour(), direction::toclient);
    84         REGISTERDATA(this->light_->getDirection(), direction::toclient);
     81        registerVariable((int &)this->type_, variableDirection::toclient, new NetworkCallback<Light>(this, &Light::changedType));
     82        registerVariable(this->light_->getDiffuseColour(), variableDirection::toclient);
     83        registerVariable(this->light_->getSpecularColour(), variableDirection::toclient);
     84        registerVariable(this->light_->getDirection(), variableDirection::toclient);
    8585    }
    8686
  • code/branches/network64/src/orxonox/objects/worldentities/Model.cc

    r2171 r2245  
    6161    void Model::registerVariables()
    6262    {
    63         REGISTERSTRING(this->meshSrc_,    direction::toclient, new NetworkCallback<Model>(this, &Model::changedMesh));
    64         REGISTERDATA(this->bCastShadows_, direction::toclient, new NetworkCallback<Model>(this, &Model::changedShadows));
     63        registerVariable(this->meshSrc_,    variableDirection::toclient, new NetworkCallback<Model>(this, &Model::changedMesh));
     64        registerVariable(this->bCastShadows_, variableDirection::toclient, new NetworkCallback<Model>(this, &Model::changedShadows));
    6565    }
    6666
  • code/branches/network64/src/orxonox/objects/worldentities/MovableEntity.cc

    r2171 r2245  
    8484    void MovableEntity::registerVariables()
    8585    {
    86         REGISTERDATA(this->velocity_.x, direction::toclient);
    87         REGISTERDATA(this->velocity_.y, direction::toclient);
    88         REGISTERDATA(this->velocity_.z, direction::toclient);
    89 
    90         REGISTERDATA(this->rotationAxis_.x, direction::toclient);
    91         REGISTERDATA(this->rotationAxis_.y, direction::toclient);
    92         REGISTERDATA(this->rotationAxis_.z, direction::toclient);
    93 
    94         REGISTERDATA(this->rotationRate_, direction::toclient);
    95 
    96         REGISTERDATA(this->overwrite_position_,    direction::toclient, new NetworkCallback<MovableEntity>(this, &MovableEntity::overwritePosition));
    97         REGISTERDATA(this->overwrite_orientation_, direction::toclient, new NetworkCallback<MovableEntity>(this, &MovableEntity::overwriteOrientation));
     86        registerVariable(this->velocity_.x, variableDirection::toclient);
     87        registerVariable(this->velocity_.y, variableDirection::toclient);
     88        registerVariable(this->velocity_.z, variableDirection::toclient);
     89 
     90        registerVariable(this->rotationAxis_.x, variableDirection::toclient);
     91        registerVariable(this->rotationAxis_.y, variableDirection::toclient);
     92        registerVariable(this->rotationAxis_.z, variableDirection::toclient);
     93 
     94        registerVariable(this->rotationRate_, variableDirection::toclient);
     95 
     96        registerVariable(this->overwrite_position_,    variableDirection::toclient, new NetworkCallback<MovableEntity>(this, &MovableEntity::overwritePosition));
     97        registerVariable(this->overwrite_orientation_, variableDirection::toclient, new NetworkCallback<MovableEntity>(this, &MovableEntity::overwriteOrientation));
    9898    }
    9999
  • code/branches/network64/src/orxonox/objects/worldentities/ParticleEmitter.cc

    r2171 r2245  
    7575    void ParticleEmitter::registerVariables()
    7676    {
    77         REGISTERSTRING(this->source_, direction::toclient, new NetworkCallback<ParticleEmitter>(this, &ParticleEmitter::sourceChanged));
    78         REGISTERDATA  (this->LOD_,    direction::toclient, new NetworkCallback<ParticleEmitter>(this, &ParticleEmitter::LODchanged));
     77        registerVariable(this->source_, variableDirection::toclient, new NetworkCallback<ParticleEmitter>(this, &ParticleEmitter::sourceChanged));
     78        registerVariable((int&)(this->LOD_),    variableDirection::toclient, new NetworkCallback<ParticleEmitter>(this, &ParticleEmitter::LODchanged));
    7979    }
    8080
  • code/branches/network64/src/orxonox/objects/worldentities/PositionableEntity.cc

    r2171 r2245  
    4848    void PositionableEntity::registerVariables()
    4949    {
    50         REGISTERDATA(this->getPosition().x, direction::toclient);
    51         REGISTERDATA(this->getPosition().y, direction::toclient);
    52         REGISTERDATA(this->getPosition().z, direction::toclient);
     50        registerVariable(this->getPosition().x, variableDirection::toclient);
     51        registerVariable(this->getPosition().y, variableDirection::toclient);
     52        registerVariable(this->getPosition().z, variableDirection::toclient);
    5353
    54         REGISTERDATA(this->getOrientation().w, direction::toclient);
    55         REGISTERDATA(this->getOrientation().x, direction::toclient);
    56         REGISTERDATA(this->getOrientation().y, direction::toclient);
    57         REGISTERDATA(this->getOrientation().z, direction::toclient);
     54        registerVariable(this->getOrientation().w, variableDirection::toclient);
     55        registerVariable(this->getOrientation().x, variableDirection::toclient);
     56        registerVariable(this->getOrientation().y, variableDirection::toclient);
     57        registerVariable(this->getOrientation().z, variableDirection::toclient);
    5858    }
    5959}
  • code/branches/network64/src/orxonox/objects/worldentities/WorldEntity.cc

    r2171 r2245  
    9696    void WorldEntity::registerVariables()
    9797    {
    98         REGISTERDATA(this->bActive_,  direction::toclient, new NetworkCallback<WorldEntity>(this, &WorldEntity::changedActivity));
    99         REGISTERDATA(this->bVisible_, direction::toclient, new NetworkCallback<WorldEntity>(this, &WorldEntity::changedVisibility));
    100 
    101         REGISTERDATA(this->getScale3D().x, direction::toclient);
    102         REGISTERDATA(this->getScale3D().y, direction::toclient);
    103         REGISTERDATA(this->getScale3D().z, direction::toclient);
    104 
    105         REGISTERDATA(this->parentID_, direction::toclient, new NetworkCallback<WorldEntity>(this, &WorldEntity::updateParent));
     98        registerVariable(this->bActive_,  variableDirection::toclient, new NetworkCallback<WorldEntity>(this, &WorldEntity::changedActivity));
     99        registerVariable(this->bVisible_, variableDirection::toclient, new NetworkCallback<WorldEntity>(this, &WorldEntity::changedVisibility));
     100 
     101        registerVariable(this->getScale3D().x, variableDirection::toclient);
     102        registerVariable(this->getScale3D().y, variableDirection::toclient);
     103        registerVariable(this->getScale3D().z, variableDirection::toclient);
     104 
     105        registerVariable(this->parentID_, variableDirection::toclient, new NetworkCallback<WorldEntity>(this, &WorldEntity::updateParent));
    106106    }
    107107
  • code/branches/network64/src/orxonox/objects/worldentities/pawns/Pawn.cc

    r2171 r2245  
    8080    void Pawn::registerVariables()
    8181    {
    82         REGISTERDATA(this->bAlive_, direction::toclient);
    83         REGISTERDATA(this->health_, direction::toclient);
     82        registerVariable(this->bAlive_, variableDirection::toclient);
     83        registerVariable(this->health_, variableDirection::toclient);
    8484    }
    8585
  • code/branches/network64/src/orxonox/objects/worldentities/pawns/SpaceShip.cc

    r2171 r2245  
    8282    void SpaceShip::registerVariables()
    8383    {
    84         REGISTERDATA(this->maxSpeed_,                direction::toclient);
    85         REGISTERDATA(this->maxSecondarySpeed_,       direction::toclient);
    86         REGISTERDATA(this->maxRotation_,             direction::toclient);
    87         REGISTERDATA(this->translationAcceleration_, direction::toclient);
    88         REGISTERDATA(this->rotationAcceleration_,    direction::toclient);
    89         REGISTERDATA(this->translationDamping_,      direction::toclient);
     84        registerVariable(this->maxSpeed_,                variableDirection::toclient);
     85        registerVariable(this->maxSecondarySpeed_,       variableDirection::toclient);
     86        registerVariable(this->maxRotation_,             variableDirection::toclient);
     87        registerVariable(this->translationAcceleration_, variableDirection::toclient);
     88        registerVariable(this->rotationAcceleration_,    variableDirection::toclient);
     89        registerVariable(this->translationDamping_,      variableDirection::toclient);
    9090    }
    9191
  • code/branches/network64/src/orxonox/objects/worldentities/pawns/Spectator.cc

    r2171 r2245  
    8686    void Spectator::registerVariables()
    8787    {
    88         REGISTERDATA(this->bGreetingFlareVisible_, direction::toclient, new NetworkCallback<Spectator>(this, &Spectator::changedFlareVisibility));
    89         REGISTERDATA(this->bGreeting_,             direction::toserver, new NetworkCallback<Spectator>(this, &Spectator::changedGreeting));
    90         REGISTERDATA(this->hudmode_,               direction::toclient);
     88        registerVariable(this->bGreetingFlareVisible_, variableDirection::toclient, new NetworkCallback<Spectator>(this, &Spectator::changedFlareVisibility));
     89        registerVariable(this->bGreeting_,             variableDirection::toserver, new NetworkCallback<Spectator>(this, &Spectator::changedGreeting));
     90        registerVariable(this->hudmode_,               variableDirection::toclient);
    9191    }
    9292
  • code/branches/network64/src/util/mbool.h

    r2171 r2245  
    3636    struct _UtilExport mbool
    3737    {
     38//        friend Synchronisable::registerVariable<>()
    3839        public:
    3940            inline mbool(bool value = false)
     
    6768            inline bool operator!() const
    6869                { return (!this->value_.bool_); }
     70           
     71            inline unsigned char& getMemory(){ return value_.memory_; }
    6972
    7073        private:
Note: See TracChangeset for help on using the changeset viewer.