Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 2309


Ignore:
Timestamp:
Dec 2, 2008, 9:10:00 PM (15 years ago)
Author:
scheusso
Message:

made some adjustments mostly to the networkid (classid) in order to have it platform independent

Location:
code/branches/network64/src
Files:
19 edited

Legend:

Unmodified
Added
Removed
  • code/branches/network64/src/core/CoreIncludes.h

    r2171 r2309  
    4848#include "Functor.h"
    4949#include "util/Debug.h"
     50#include "util/Integers.h"
    5051
    5152
  • code/branches/network64/src/core/Factory.cc

    r2171 r2309  
    5858        @return The Identifier
    5959    */
    60     Identifier* Factory::getIdentifier(const unsigned int id)
     60    Identifier* Factory::getIdentifier(const uint32_t id)
    6161    {
    62         std::map<unsigned int, Identifier*>::const_iterator it = getFactoryPointer()->identifierNetworkIDMap_.find(id);
     62        std::map<uint32_t, Identifier*>::const_iterator it = getFactoryPointer()->identifierNetworkIDMap_.find(id);
    6363        if (it != getFactoryPointer()->identifierNetworkIDMap_.end())
    6464            return it->second;
     
    8585        @param newID The new networkID
    8686    */
    87     void Factory::changeNetworkID(Identifier* identifier, const unsigned int oldID, const unsigned int newID)
     87    void Factory::changeNetworkID(Identifier* identifier, const uint32_t oldID, const uint32_t newID)
    8888    {
    8989        getFactoryPointer()->identifierNetworkIDMap_.erase(oldID);
  • code/branches/network64/src/core/Factory.h

    r2171 r2309  
    4949#include <map>
    5050#include <string>
     51#include "util/Integers.h"
    5152
    5253namespace orxonox
     
    6061        public:
    6162            static Identifier* getIdentifier(const std::string& name);
    62             static Identifier* getIdentifier(const unsigned int id);
     63            static Identifier* getIdentifier(const uint32_t id);
    6364            static void add(const std::string& name, Identifier* identifier);
    64             static void changeNetworkID(Identifier* identifier, const unsigned int oldID, const unsigned int newID);
     65            static void changeNetworkID(Identifier* identifier, const uint32_t oldID, const uint32_t newID);
    6566            static void createClassHierarchy();
    6667
     
    8384
    8485            std::map<std::string, Identifier*> identifierStringMap_;            //!< The map, mapping the name with the Identifier
    85             std::map<unsigned int, Identifier*> identifierNetworkIDMap_;        //!< The map, mapping the network ID with the Identifier
     86            std::map<uint32_t, Identifier*> identifierNetworkIDMap_;        //!< The map, mapping the network ID with the Identifier
    8687    };
    8788
  • code/branches/network64/src/core/Identifier.cc

    r2171 r2309  
    235235        @param id The new network ID
    236236    */
    237     void Identifier::setNetworkID(unsigned int id)
     237    void Identifier::setNetworkID(uint32_t id)
    238238    {
    239239        Factory::changeNetworkID(this, this->classID_, id);
  • code/branches/network64/src/core/Identifier.h

    r2171 r2309  
    230230
    231231            /** @brief Returns the network ID to identify a class through the network. @return the network ID */
    232             inline const unsigned int getNetworkID() const { return this->classID_; }
     232            inline const uint32_t getNetworkID() const { return this->classID_; }
    233233
    234234            /** @brief Sets the network ID to a new value. @param id The new value */
    235             void setNetworkID(unsigned int id);
     235            void setNetworkID(uint32_t id);
    236236
    237237            void addConfigValueContainer(const std::string& varname, ConfigValueContainer* container);
     
    315315            BaseFactory* factory_;                                         //!< The Factory, able to create new objects of the given class (if available)
    316316            static int hierarchyCreatingCounter_s;                         //!< Bigger than zero if at least one Identifier stores its parents (its an int instead of a bool to avoid conflicts with multithreading)
    317             unsigned int classID_;                                         //!< The network ID to identify a class through the network
     317            uint32_t classID_;                                             //!< The network ID to identify a class through the network
    318318
    319319            bool bHasConfigValues_;                                        //!< True if this class has at least one assigned config value
  • code/branches/network64/src/network/GamestateClient.cc

    r2211 r2309  
    3636#include "core/Iterator.h"
    3737#include "synchronisable/Synchronisable.h"
     38#include "synchronisable/NetworkCallbackManager.h"
    3839#include "packet/Acknowledgement.h"
    3940
     
    7778    packet::Gamestate *processed = processGamestate(tempGamestate_);
    7879//    assert(processed);
     80   
     81    //now call the queued callbacks
     82    NetworkCallbackManager::callCallbacks();
     83   
    7984    if (!processed)
    8085        return false;
  • code/branches/network64/src/network/GamestateManager.cc

    r2211 r2309  
    5050#include "ClientInformation.h"
    5151#include "synchronisable/Synchronisable.h"
     52#include "synchronisable/NetworkCallbackManager.h"
    5253
    5354namespace orxonox
     
    8687    // now clear the queue
    8788    gamestateQueue.clear();
     89    //and call all queued callbacks
     90    NetworkCallbackManager::callCallbacks();
    8891    return true;
    8992  }
  • code/branches/network64/src/network/NetworkPrereqs.h

    r2245 r2309  
    7171  class GamestateHandler;
    7272  class NetworkCallbackBase;
     73  template <class T> class NetworkCallback;
     74  class NetworkCallbackManager;
    7375  class PacketBuffer;
    7476  class Server;
  • code/branches/network64/src/network/packet/Gamestate.cc

    r2171 r2309  
    7373bool Gamestate::collectData(int id, uint8_t mode)
    7474{
    75   unsigned int tempsize=0, currentsize=0;
     75  uint32_t tempsize=0, currentsize=0;
    7676  assert(data_==0);
    77   unsigned int size = calcGamestateSize(id, mode);
     77  uint32_t size = calcGamestateSize(id, mode);
    7878
    7979  COUT(4) << "G.ST.Man: producing gamestate with id: " << id << std::endl;
     
    166166}
    167167
    168 unsigned int Gamestate::getSize() const
     168uint32_t Gamestate::getSize() const
    169169{
    170170  assert(data_);
     
    251251  assert(HEADER->compressed);
    252252  COUT(4) << "GameStateClient: uncompressing gamestate. id: " << HEADER->id << ", baseid: " << HEADER->base_id << ", datasize: " << HEADER->datasize << ", compsize: " << HEADER->compsize << std::endl;
    253   unsigned int datasize = HEADER->datasize;
    254   unsigned int compsize = HEADER->compsize;
    255   unsigned int bufsize;
     253  uint32_t datasize = HEADER->datasize;
     254  uint32_t compsize = HEADER->compsize;
     255  uint32_t bufsize;
    256256//  assert(compsize<=datasize);
    257257  bufsize = datasize;
     
    302302  //unsigned char *basep = base->getGs()/*, *gs = getGs()*/;
    303303  uint8_t *basep = GAMESTATE_START(base->data_), *gs = GAMESTATE_START(this->data_);
    304   unsigned int of=0; // pointers offset
    305   unsigned int dest_length=0;
     304  uint32_t of=0; // pointers offset
     305  uint32_t dest_length=0;
    306306  dest_length=HEADER->datasize;
    307307  if(dest_length==0)
     
    334334Gamestate* Gamestate::doSelection(unsigned int clientID){
    335335  assert(data_);
    336   std::map<unsigned int, Synchronisable *>::iterator it;
     336  std::map<uint32_t, Synchronisable *>::iterator it;
    337337
    338338  // allocate memory for new data
     
    347347
    348348  synchronisableHeader *oldobjectheader, *newobjectheader;
    349   unsigned int objectOffset;
     349  uint32_t objectOffset;
    350350
    351351  //copy in the zeros
     
    353353    oldobjectheader = (synchronisableHeader*)origdata;
    354354    newobjectheader = (synchronisableHeader*)newdata;
    355     unsigned int objectsize = oldobjectheader->size;
     355    uint32_t objectsize = oldobjectheader->size;
    356356    assert(it->second->objectID==oldobjectheader->objectID);
    357357    *newobjectheader = *oldobjectheader;
     
    382382
    383383  //preparations
    384   std::map<unsigned int, Synchronisable *>::iterator it;
     384  std::map<uint32_t, Synchronisable *>::iterator it;
    385385  uint8_t *origdata, *basedata, *destdata, *ndata;
    386   unsigned int objectOffset, streamOffset=0;    //data offset
    387   unsigned int minsize = (HEADER->datasize < GAMESTATE_HEADER(base->data_)->datasize) ? HEADER->datasize : GAMESTATE_HEADER(base->data_)->datasize;
     386  uint32_t objectOffset, streamOffset=0;    //data offset
     387  uint32_t minsize = (HEADER->datasize < GAMESTATE_HEADER(base->data_)->datasize) ? HEADER->datasize : GAMESTATE_HEADER(base->data_)->datasize;
    388388  synchronisableHeader *origheader;
    389389  synchronisableHeader *destheader;
     
    402402
    403403    //copy and partially diff the object header
    404     assert(sizeof(synchronisableHeader)==3*sizeof(unsigned int)+sizeof(bool));
     404    assert(sizeof(synchronisableHeader)==3*sizeof(uint32_t)+sizeof(bool));
    405405    *(uint32_t*)destdata = *(uint32_t*)origdata; //size (do not diff)
    406406    *(bool*)(destdata+sizeof(uint32_t)) = sendData;
     
    450450
    451451  //preparations
    452   std::map<unsigned int, Synchronisable *>::iterator it;
     452  std::map<uint32_t, Synchronisable *>::iterator it;
    453453  uint8_t *origdata, *basedata, *destdata, *ndata;
    454   unsigned int objectOffset, streamOffset=0;    //data offset
    455   unsigned int minsize = (HEADER->datasize < GAMESTATE_HEADER(base->data_)->datasize) ? HEADER->datasize : GAMESTATE_HEADER(base->data_)->datasize;
     454  uint32_t objectOffset, streamOffset=0;    //data offset
     455  uint32_t minsize = (HEADER->datasize < GAMESTATE_HEADER(base->data_)->datasize) ? HEADER->datasize : GAMESTATE_HEADER(base->data_)->datasize;
    456456  synchronisableHeader *origheader;
    457457  synchronisableHeader *destheader;
     
    470470
    471471    //copy and partially diff the object header
    472     assert(sizeof(synchronisableHeader)==3*sizeof(unsigned int)+sizeof(bool));
    473     *(unsigned int*)destdata = *(unsigned int*)origdata; //size (do not diff)
    474     *(bool*)(destdata+sizeof(unsigned int)) = *(bool*)(origdata+sizeof(unsigned int));
    475     sendData = *(bool*)(origdata+sizeof(unsigned int));
     472    assert(sizeof(synchronisableHeader)==3*sizeof(uint32_t)+sizeof(bool));
     473    *(uint32_t*)destdata = *(uint32_t*)origdata; //size (do not diff)
     474    *(bool*)(destdata+sizeof(uint32_t)) = *(bool*)(origdata+sizeof(uint32_t));
     475    sendData = *(bool*)(origdata+sizeof(uint32_t));
    476476    if(sendData){
    477       *(unsigned int*)(destdata+sizeof(unsigned int)+sizeof(bool)) = *(unsigned int*)(basedata+sizeof(unsigned int)+sizeof(bool)) ^ *(unsigned int*)(origdata+sizeof(unsigned int)+sizeof(bool)); //objectid (diff it)
    478       *(unsigned int*)(destdata+2*sizeof(unsigned int)+sizeof(bool)) = *(unsigned int*)(basedata+2*sizeof(unsigned int)+sizeof(bool)) ^ *(unsigned int*)(origdata+2*sizeof(unsigned int)+sizeof(bool)); //classid (diff it)
     477      *(uint32_t*)(destdata+sizeof(uint32_t)+sizeof(bool)) = *(uint32_t*)(basedata+sizeof(uint32_t)+sizeof(bool)) ^ *(uint32_t*)(origdata+sizeof(uint32_t)+sizeof(bool)); //objectid (diff it)
     478      *(uint32_t*)(destdata+2*sizeof(uint32_t)+sizeof(bool)) = *(uint32_t*)(basedata+2*sizeof(uint32_t)+sizeof(bool)) ^ *(uint32_t*)(origdata+2*sizeof(uint32_t)+sizeof(bool)); //classid (diff it)
    479479    }else{
    480       *(unsigned int*)(destdata+sizeof(unsigned int)+sizeof(bool)) = 0;
    481       *(unsigned int*)(destdata+2*sizeof(unsigned int)+sizeof(bool)) = 0;
     480      *(uint32_t*)(destdata+sizeof(uint32_t)+sizeof(bool)) = 0;
     481      *(uint32_t*)(destdata+2*sizeof(uint32_t)+sizeof(bool)) = 0;
    482482    }
    483483    objectOffset=sizeof(synchronisableHeader);
     
    517517  uint8_t *basep = GAMESTATE_START(base->data_);
    518518  uint8_t *gs = GAMESTATE_START(this->data_);
    519   unsigned int of=0; // pointers offset
    520   unsigned int dest_length=0;
     519  uint32_t of=0; // pointers offset
     520  uint32_t dest_length=0;
    521521  dest_length=HEADER->datasize;
    522522  if(dest_length==0)
     
    548548
    549549
    550 unsigned int Gamestate::calcGamestateSize(unsigned int id, uint8_t mode)
    551 {
    552   unsigned int size=0;
     550uint32_t Gamestate::calcGamestateSize(int32_t id, uint8_t mode)
     551{
     552  uint32_t size=0;
    553553    // get the start of the Synchronisable list
    554554  ObjectList<Synchronisable>::iterator it;
  • code/branches/network64/src/network/packet/Gamestate.h

    r2211 r2309  
    8585    // Packet functions
    8686  private:
    87     virtual unsigned int getSize() const;
     87    virtual uint32_t getSize() const;
    8888    virtual bool process();
    8989
    9090    bool operator ==(packet::Gamestate gs);
    9191  private:
    92     unsigned int calcGamestateSize(unsigned int id, uint8_t mode=0x0);
     92    uint32_t calcGamestateSize(int32_t id, uint8_t mode=0x0);
    9393    void removeObject(ObjectListIterator<Synchronisable> &it);
    94     std::map<unsigned int, Synchronisable*> dataMap_;
     94    std::map<uint32_t, Synchronisable*> dataMap_;
    9595};
    9696
  • code/branches/network64/src/network/synchronisable/CMakeLists.txt

    r2307 r2309  
    11SET( SRC_FILES
     2  NetworkCallbackManager.cc
    23  Synchronisable.cc
    34  SynchronisableSpecialisations.cc
  • code/branches/network64/src/network/synchronisable/NetworkCallback.h

    r2211 r2309  
     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 *      Oliver Scheuss, (C) 2008
     24 *   Co-authors:
     25 *      ...
     26 *
     27 */
     28
     29
    130#ifndef _NETWORK_CALLBACK__
    231#define _NETWORK_CALLBACK__
    332
    433#include "network/NetworkPrereqs.h"
     34#include "NetworkCallbackManager.h"
    535
    636namespace orxonox{
     37 
    738  class _NetworkExport NetworkCallbackBase
    839  {
    940    public:
    1041      virtual void call() = 0;
    11           virtual ~NetworkCallbackBase() {}
     42      NetworkCallbackBase(){ NetworkCallbackManager::registerCallback( this ); }
     43      virtual ~NetworkCallbackBase() {}
    1244  };
    1345
     
    2658  };
    2759
    28 
    2960}
    3061
  • code/branches/network64/src/network/synchronisable/Synchronisable.cc

    r2307 r2309  
    5555
    5656
    57   std::map<unsigned int, Synchronisable *> Synchronisable::objectMap_;
    58   std::queue<unsigned int> Synchronisable::deletedObjects_;
     57  std::map<uint32_t, Synchronisable *> Synchronisable::objectMap_;
     58  std::queue<uint32_t> Synchronisable::deletedObjects_;
    5959
    6060  uint8_t Synchronisable::state_=0x1; // detemines wheter we are server (default) or client
     
    7777    else
    7878      objectID=OBJECTID_UNKNOWN;
    79     classID = (unsigned int)-1;
     79    classID = static_cast<uint32_t>(-1);
    8080
    8181
     
    122122//       objectMap_.erase(objectID);
    123123    }
    124     std::map<unsigned int, Synchronisable*>::iterator it;
     124    std::map<uint32_t, Synchronisable*>::iterator it;
    125125    it = objectMap_.find(objectID);
    126126    if (it != objectMap_.end())
     
    199199   * @return true/false
    200200   */
    201   bool Synchronisable::deleteObject(unsigned int objectID){
     201  bool Synchronisable::deleteObject(uint32_t objectID){
    202202//     assert(getSynchronisable(objectID));
    203203    if(!getSynchronisable(objectID))
     
    218218   * @return pointer to the Synchronisable with the objectID
    219219   */
    220   Synchronisable* Synchronisable::getSynchronisable(unsigned int objectID){
    221     std::map<unsigned int, Synchronisable*>::iterator it1;
     220  Synchronisable* Synchronisable::getSynchronisable(uint32_t objectID){
     221    std::map<uint32_t, Synchronisable*>::iterator it1;
    222222    it1 = objectMap_.find(objectID);
    223223    if (it1 != objectMap_.end())
     
    295295   * @return true: if !doSync or if everything was successfully saved
    296296   */
    297   bool Synchronisable::getData(uint8_t*& mem, unsigned int id, uint8_t mode){
     297  bool Synchronisable::getData(uint8_t*& mem, int32_t id, uint8_t mode){
    298298    if(mode==0x0)
    299299      mode=state_;
     
    302302      return true;
    303303    //std::cout << "inside getData" << std::endl;
    304     unsigned int tempsize = 0;
     304    uint32_t tempsize = 0;
    305305    if(classID==0)
    306306      COUT(3) << "classid 0 " << this->getIdentifier()->getName() << std::endl;
    307307
    308     if (this->classID == (unsigned int)-1)
     308    if (this->classID == static_cast<uint32_t>(-1))
    309309        this->classID = this->getIdentifier()->getNetworkID();
    310310
     
    312312//     this->classID=this->getIdentifier()->getNetworkID(); // TODO: correct this
    313313    std::list<SynchronisableVariableBase*>::iterator i;
    314     unsigned int size;
     314    uint32_t size;
    315315    size=getSize(id, mode);
    316316
     
    384384  * @return amount of bytes
    385385  */
    386   uint32_t Synchronisable::getSize(unsigned int id, uint8_t mode){
     386  uint32_t Synchronisable::getSize(int32_t id, uint8_t mode){
    387387    int tsize=sizeof(synchronisableHeader);
    388388    if(mode==0x0)
     
    402402   * @return true/false
    403403   */
    404   bool Synchronisable::doSync(unsigned int id, uint8_t mode){
     404  bool Synchronisable::doSync(int32_t id, uint8_t mode){
    405405    if(mode==0x0)
    406406      mode=state_;
     
    408408  }
    409409
    410   bool Synchronisable::doSelection(unsigned int id){
     410  bool Synchronisable::doSelection(int32_t id){
    411411    return true; //TODO: change this
    412412    //return ( id==0 || id%objectFrequency_==objectID%objectFrequency_ ) && ((objectMode_&state_)!=0);
  • code/branches/network64/src/network/synchronisable/Synchronisable.h

    r2307 r2309  
    5353namespace orxonox
    5454{
    55   static const unsigned int OBJECTID_UNKNOWN = (unsigned int)-1;
     55  static const uint32_t OBJECTID_UNKNOWN = static_cast<uint32_t>(-1);
    5656
    5757  namespace objectDirection{
     
    8686
    8787    static Synchronisable *fabricate(uint8_t*& mem, uint8_t mode=0x0);
    88     static bool deleteObject(unsigned int objectID);
    89     static Synchronisable *getSynchronisable(unsigned int objectID);
     88    static bool deleteObject(uint32_t objectID);
     89    static Synchronisable *getSynchronisable(uint32_t objectID);
    9090    static unsigned int getNumberOfDeletedObject(){ return deletedObjects_.size(); }
    91     static unsigned int popDeletedObject(){ unsigned int i = deletedObjects_.front(); deletedObjects_.pop(); return i; }
     91    static uint32_t popDeletedObject(){ uint32_t i = deletedObjects_.front(); deletedObjects_.pop(); return i; }
    9292
    93     inline unsigned int getObjectID(){return objectID;}
    94     inline unsigned int getClassID(){return classID;}
     93    inline uint32_t getObjectID(){return objectID;}
     94    inline uint32_t getClassID(){return classID;}
    9595  protected:
    9696    Synchronisable(BaseObject* creator);
     
    103103
    104104  private:
    105     bool getData(uint8_t*& men, unsigned int id, uint8_t mode=0x0);
    106     uint32_t getSize(unsigned int id, uint8_t mode=0x0);
     105    bool getData(uint8_t*& men, int32_t id, uint8_t mode=0x0);
     106    uint32_t getSize(int32_t id, uint8_t mode=0x0);
    107107    bool updateData(uint8_t*& mem, uint8_t mode=0x0, bool forceCallback=false);
    108108    bool isMyData(uint8_t* mem);
    109     bool doSelection(unsigned int id);
    110     bool doSync(unsigned int id, uint8_t mode=0x0);
     109    bool doSelection(int32_t id);
     110    bool doSync(int32_t id, uint8_t mode=0x0);
    111111
    112     unsigned int objectID;
    113     unsigned int creatorID;
    114     unsigned int classID;
     112    uint32_t objectID;
     113    uint32_t creatorID;
     114    uint32_t classID;
    115115
    116116    std::list<SynchronisableVariableBase*> syncList;
     
    119119    unsigned int objectFrequency_;
    120120    int objectMode_;
    121     static std::map<unsigned int, Synchronisable *> objectMap_;
    122     static std::queue<unsigned int> deletedObjects_;
     121    static std::map<uint32_t, Synchronisable *> objectMap_;
     122    static std::queue<uint32_t> deletedObjects_;
    123123  };
    124124 
  • code/branches/network64/src/network/synchronisable/SynchronisableSpecialisations.cc

    r2307 r2309  
    3737  template <> void Synchronisable::registerVariable( const ColourValue& variable, uint8_t mode, NetworkCallbackBase* cb, bool bidirectional)
    3838  {
    39     registerVariable(variable.r, mode, 0, bidirectional);
    40     registerVariable(variable.g, mode, 0, bidirectional);
    41     registerVariable(variable.b, mode, 0, bidirectional);
     39    registerVariable(variable.r, mode, cb, bidirectional);
     40    registerVariable(variable.g, mode, cb, bidirectional);
     41    registerVariable(variable.b, mode, cb, bidirectional);
    4242    registerVariable(variable.a, mode, cb, bidirectional);
    4343  }
     
    4949  template <> void Synchronisable::registerVariable( const Vector2& variable, uint8_t mode, NetworkCallbackBase* cb, bool bidirectional)
    5050  {
    51     registerVariable(variable.x, mode, 0, bidirectional);
     51    registerVariable(variable.x, mode, cb, bidirectional);
    5252    registerVariable(variable.y, mode, cb, bidirectional);
    5353  }
     
    5959  template <> void Synchronisable::registerVariable( const Vector3& variable, uint8_t mode, NetworkCallbackBase* cb, bool bidirectional)
    6060  {
    61     registerVariable(variable.x, mode, 0, bidirectional);
    62     registerVariable(variable.y, mode, 0, bidirectional);
     61    registerVariable(variable.x, mode, cb, bidirectional);
     62    registerVariable(variable.y, mode, cb, bidirectional);
    6363    registerVariable(variable.z, mode, cb, bidirectional);
    6464  }
     
    7070  template <> void Synchronisable::registerVariable( const Vector4& variable, uint8_t mode, NetworkCallbackBase* cb, bool bidirectional)
    7171  {
    72     registerVariable(variable.x, mode, 0, bidirectional);
    73     registerVariable(variable.y, mode, 0, bidirectional);
    74     registerVariable(variable.z, mode, 0, bidirectional);
     72    registerVariable(variable.x, mode, cb, bidirectional);
     73    registerVariable(variable.y, mode, cb, bidirectional);
     74    registerVariable(variable.z, mode, cb, bidirectional);
    7575    registerVariable(variable.w, mode, cb, bidirectional);
    7676  }
     
    8787  template <> void Synchronisable::registerVariable( const Quaternion& variable, uint8_t mode, NetworkCallbackBase* cb, bool bidirectional)
    8888  {
    89     registerVariable(variable.w, mode, 0, bidirectional);
    90     registerVariable(variable.x, mode, 0, bidirectional);
    91     registerVariable(variable.y, mode, 0, bidirectional);
     89    registerVariable(variable.x, mode, cb, bidirectional);
     90    registerVariable(variable.y, mode, cb, bidirectional);
    9291    registerVariable(variable.z, mode, cb, bidirectional);
     92    registerVariable(variable.w, mode, cb, bidirectional);
    9393  }
    9494  template <> void Synchronisable::registerVariable( Quaternion& variable, uint8_t mode, NetworkCallbackBase* cb, bool bidirectional)
  • code/branches/network64/src/network/synchronisable/SynchronisableVariable.cc

    r2255 r2309  
    6464}
    6565
     66// =========== char
     67
     68template <> uint32_t SynchronisableVariable<const char>::returnSize()
     69{
     70  return sizeof(uint8_t);
     71}
     72
     73template <> void SynchronisableVariable<const char>::setAndIncrease( uint8_t*& mem )
     74{
     75  *(uint8_t*)(&this->variable_) = *static_cast<uint8_t*>(mem);
     76  mem += SynchronisableVariable<const char>::returnSize();
     77}
     78
     79template <> void SynchronisableVariable<const char>::getAndIncrease( uint8_t*& mem )
     80{
     81  *static_cast<uint8_t*>(mem) = *(uint8_t*)(&this->variable_);
     82  mem += SynchronisableVariable<const char>::returnSize();
     83}
     84
     85template <> bool SynchronisableVariable<const char>::checkEquality( uint8_t* mem )
     86{
     87  return *static_cast<uint8_t*>(mem) == *(uint8_t*)(&this->variable_);
     88}
     89
    6690// =========== unsigned char
    6791
  • code/branches/network64/src/network/synchronisable/SynchronisableVariable.h

    r2307 r2309  
    3939#include "core/CoreIncludes.h"
    4040#include "network/synchronisable/NetworkCallback.h"
     41#include "network/synchronisable/NetworkCallbackManager.h"
    4142
    4243namespace orxonox{
     
    119120  {
    120121    if (this->callback_ != 0)
    121       delete this->callback_;
     122      NetworkCallbackManager::deleteCallback(this->callback_); //safe call for deletion
    122123  }
    123124
     
    146147  // now do a callback if neccessary
    147148    if ( callback )
    148       this->callback_->call();
     149      NetworkCallbackManager::triggerCallback( this->callback_ );
     150      //this->callback_->call();
    149151  }
    150152
     
    299301  // now do a callback if neccessary
    300302      if ( callback )
    301         this->callback_->call();
     303        NetworkCallbackManager::triggerCallback( this->callback_ );
     304        //this->callback_->call();
    302305    }
    303306
  • code/branches/network64/src/orxonox/objects/Test.cc

    r2245 r2309  
    6161        void Test::setConfigValues()
    6262        {
    63                 SetConfigValue ( v1, 1 )/*.callback ( this, &Test::checkV1 )*/;
    64     SetConfigValue ( v2, 2 )/*.callback ( this, &Test::checkV2 )*/;
    65     SetConfigValue ( v3, 3 )/*.callback ( this, &Test::checkV3 )*/;
    66     SetConfigValue ( v4, 4 )/*.callback ( this, &Test::checkV4 )*/;
     63                SetConfigValue ( u1, 1 )/*.callback ( this, &Test::checkV1 )*/;
     64    SetConfigValue ( u2, 2 )/*.callback ( this, &Test::checkV2 )*/;
     65    SetConfigValue ( u3, 3 )/*.callback ( this, &Test::checkV3 )*/;
     66    SetConfigValue ( u4, 4 )/*.callback ( this, &Test::checkV4 )*/;
     67   
     68    SetConfigValue ( s1, 1 )/*.callback ( this, &Test::checkV1 )*/;
     69    SetConfigValue ( s2, 2 )/*.callback ( this, &Test::checkV2 )*/;
     70    SetConfigValue ( s3, 3 )/*.callback ( this, &Test::checkV3 )*/;
     71    SetConfigValue ( s4, 4 )/*.callback ( this, &Test::checkV4 )*/;
    6772        }
    6873
     
    7075        void Test::registerVariables()
    7176        {
    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 );
     77                registerVariable ( u1, variableDirection::toclient, new NetworkCallback<Test> ( this, &Test::checkU1 ));
     78    registerVariable ( u2, variableDirection::toserver, new NetworkCallback<Test> ( this, &Test::checkU2 ));
     79                registerVariable ( u3, variableDirection::serverMaster, new NetworkCallback<Test> ( this, &Test::checkU3 ), true );
     80    registerVariable ( u4, variableDirection::clientMaster, new NetworkCallback<Test> ( this, &Test::checkU4 ), true );
     81   
     82    registerVariable ( s1, variableDirection::toclient, new NetworkCallback<Test> ( this, &Test::checkS1 ));
     83    registerVariable ( s2, variableDirection::toserver, new NetworkCallback<Test> ( this, &Test::checkS2 ));
     84    registerVariable ( s3, variableDirection::serverMaster, new NetworkCallback<Test> ( this, &Test::checkS3 ), true );
     85    registerVariable ( s4, variableDirection::clientMaster, new NetworkCallback<Test> ( this, &Test::checkS4 ), true );
    7686        }
    7787
    78   void Test::checkV1(){
    79     COUT(1) << "V1 changed: " << v1 << std::endl;
    80   }
     88  void Test::checkU1(){ COUT(1) << "U1 changed: " << u1 << std::endl; }
     89  void Test::checkU2(){ COUT(1) << "U2 changed: " << u2 << std::endl; }
     90  void Test::checkU3(){ COUT(1) << "U3 changed: " << u3 << std::endl; }
     91  void Test::checkU4(){ COUT(1) << "U4 changed: " << u4 << std::endl; }
    8192
    82   void Test::checkV2(){
    83     COUT(1) << "V2 changed: " << v2 << std::endl;
    84   }
    85 
    86   void Test::checkV3(){
    87     COUT(1) << "V3 changed: " << v3 << std::endl;
    88   }
    89  
    90   void Test::checkV4(){
    91     COUT(1) << "V4 changed: " << v4 << std::endl;
    92   }
    93 
     93  void Test::checkS1(){ COUT(1) << "S1 changed: " << s1 << std::endl; }
     94  void Test::checkS2(){ COUT(1) << "S2 changed: " << s2 << std::endl; }
     95  void Test::checkS3(){ COUT(1) << "S3 changed: " << s3 << std::endl; }
     96  void Test::checkS4(){ COUT(1) << "S4 changed: " << s4 << std::endl; }
    9497
    9598}
  • code/branches/network64/src/orxonox/objects/Test.h

    r2245 r2309  
    3434#include "network/synchronisable/Synchronisable.h"
    3535
     36
     37typedef int TYPE;
     38typedef unsigned int UTYPE;
     39
     40
    3641namespace orxonox
    3742{
     
    4550      void registerVariables();
    4651
    47       void setV1(unsigned int value){ v1 = value; }
    48       void setV2(unsigned int value){ v2 = value; }
    49       void setV3(unsigned int value){ v3 = value; }
    50       void setV4(unsigned int value){ v4 = value; }
    5152
    52       void checkV1();
    53       void checkV2();
    54       void checkV3();
    55       void checkV4();
     53      //unsigned functions
     54      void setU1(UTYPE value){ u1 = value; }
     55      void setU2(UTYPE value){ u2 = value; }
     56      void setU3(UTYPE value){ u3 = value; }
     57      void setU4(UTYPE value){ u4 = value; }
     58      void checkU1();
     59      void checkU2();
     60      void checkU3();
     61      void checkU4();
    5662     
    57       static void printV1(){ instance_->checkV1(); }
    58       static void printV2(){ instance_->checkV2(); }
    59       static void printV3(){ instance_->checkV3(); }
    60       static void printV4(){ instance_->checkV4(); }
     63      //signed functions
     64      void setS1(TYPE value){ s1 = value; }
     65      void setS2(TYPE value){ s2 = value; }
     66      void setS3(TYPE value){ s3 = value; }
     67      void setS4(TYPE value){ s4 = value; }
     68      void checkS1();
     69      void checkS2();
     70      void checkS3();
     71      void checkS4();
     72     
     73      static void printV1(){ instance_->checkU1(); }
     74      static void printV2(){ instance_->checkU2(); }
     75      static void printV3(){ instance_->checkU3(); }
     76      static void printV4(){ instance_->checkU4(); }
    6177
    6278    private:
    63       unsigned int v1;
    64       unsigned int v2;
    65       unsigned int v3;
    66       unsigned int v4;
     79      UTYPE u1;
     80      UTYPE u2;
     81      UTYPE u3;
     82      UTYPE u4;
     83     
     84      TYPE s1;
     85      TYPE s2;
     86      TYPE s3;
     87      TYPE s4;
    6788     
    6889      static Test* instance_;
Note: See TracChangeset for help on using the changeset viewer.