Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Dec 25, 2009, 10:23:58 PM (15 years ago)
Author:
rgrieder
Message:

Merged presentation2 branch back to trunk.
Major new features:

  • Actual GUI with settings, etc.
  • Improved space ship steering (human interaction)
  • Rocket fire and more particle effects
  • Advanced sound framework
Location:
code/trunk
Files:
1 deleted
8 edited
1 copied

Legend:

Unmodified
Added
Removed
  • code/trunk

  • code/trunk/src/libraries/network/synchronisable/CMakeLists.txt

    r5781 r6417  
    22  NetworkCallbackManager.cc
    33  Synchronisable.cc
    4   SynchronisableSpecialisations.cc
    54  SynchronisableVariable.cc
    65)
  • code/trunk/src/libraries/network/synchronisable/NetworkCallback.h

    r6073 r6417  
    3333#include "network/NetworkPrereqs.h"
    3434#include "NetworkCallbackManager.h"
     35// #include "util/MultiType.h"
    3536
    3637namespace orxonox{
    37  
     38
     39  struct EmptyType{};
     40
    3841  class _NetworkExport NetworkCallbackBase
    3942  {
     
    5861  };
    5962
     63  template <class T, class U>
     64  class NetworkCallbackNotify: public NetworkCallbackBase
     65  {
     66    public:
     67      NetworkCallbackNotify(T* object, void (T::*function) (const U&)) : object_(object), function_(function) {}
     68      NetworkCallbackNotify() {}
     69      virtual ~NetworkCallbackNotify() {}
     70      virtual void call()
     71        { (this->object_->*function_)( this->oldValue_ ); }
     72      void setOldValue(const U& value){ this->oldValue_ = value; }
     73    private:
     74      T* object_;
     75      U oldValue_;
     76      void (T::*function_) (const U&);
     77  };
     78
    6079}
    6180
  • code/trunk/src/libraries/network/synchronisable/NetworkCallbackManager.cc

    r5781 r6417  
    2626 *
    2727 */
    28  
     28
    2929#include "NetworkCallbackManager.h"
    3030#include "NetworkCallback.h"
    3131
    3232namespace orxonox{
    33  
     33
    3434  std::set<NetworkCallbackBase*> NetworkCallbackManager::callbackSet_;
    3535  std::queue<NetworkCallbackBase*> NetworkCallbackManager::triggeredCallbacks_;
    36  
     36
    3737  void NetworkCallbackManager::registerCallback(NetworkCallbackBase *cb)
    38   { 
    39     callbackSet_.insert(cb); 
     38  {
     39    callbackSet_.insert(cb);
    4040  }
    4141  void NetworkCallbackManager::deleteCallback(NetworkCallbackBase *cb)
     
    4848    }
    4949  }
    50  
     50
    5151  void NetworkCallbackManager::triggerCallback(NetworkCallbackBase *cb)
    5252  {
  • code/trunk/src/libraries/network/synchronisable/NetworkCallbackManager.h

    r5781 r6417  
    3737
    3838namespace orxonox{
    39  
     39
    4040  class _NetworkExport NetworkCallbackManager{
    4141    public:
     
    4848      static std::queue<NetworkCallbackBase*> triggeredCallbacks_;
    4949  };
    50  
     50
    5151
    5252}
  • code/trunk/src/libraries/network/synchronisable/Synchronisable.cc

    r5929 r6417  
    6262    }
    6363    classID_ = static_cast<uint32_t>(-1);
    64    
     64
    6565    // set dataSize to 0
    6666    this->dataSize_ = 0;
     
    277277      //tempsize += (*i)->getSize( mode );
    278278    }
    279    
     279
    280280    tempsize += SynchronisableHeader::getSize();
    281281    header.setObjectID( this->objectID_ );
     
    284284    header.setDataAvailable( true );
    285285    header.setDataSize( tempsize );
    286    
     286
    287287#ifndef NDEBUG
    288288    uint32_t size;
     
    390390  }
    391391
     392  template <> void Synchronisable::registerVariable( std::string& variable, uint8_t mode, NetworkCallbackBase *cb, bool bidirectional)
     393  {
     394    SynchronisableVariableBase* sv;
     395    if (bidirectional)
     396      sv = new SynchronisableVariableBidirectional<std::string>(variable, mode, cb);
     397    else
     398      sv = new SynchronisableVariable<std::string>(variable, mode, cb);
     399    syncList.push_back(sv);
     400    stringList.push_back(sv);
     401  }
     402
    392403
    393404}
  • code/trunk/src/libraries/network/synchronisable/Synchronisable.h

    r5929 r6417  
    6666
    6767  /**
    68    * @brief: stores information about a Synchronisable 
    69    * 
     68   * @brief: stores information about a Synchronisable
     69   *
    7070   * This class stores the information about a Synchronisable (objectID_, classID_, creatorID_, dataSize)
    7171   * in an emulated bitset.
     
    132132    inline unsigned int getPriority() const { return this->objectFrequency_;}
    133133    inline uint8_t getSyncMode() const { return this->objectMode_; }
    134    
     134
    135135    void setSyncMode(uint8_t mode);
    136136
     
    138138    Synchronisable(BaseObject* creator);
    139139    template <class T> void registerVariable(T& variable, uint8_t mode=0x1, NetworkCallbackBase *cb=0, bool bidirectional=false);
    140     //template <class T> void unregisterVariable(T& var);
     140
    141141    void setPriority(unsigned int freq){ objectFrequency_ = freq; }
    142142
     
    148148    bool isMyData(uint8_t* mem);
    149149    bool doSync(int32_t id, uint8_t mode=0x0);
    150    
     150
    151151    inline void setObjectID(uint32_t id){ this->objectID_ = id; objectMap_[this->objectID_] = this; }
    152152    inline void setClassID(uint32_t id){ this->classID_ = id; }
     
    167167  };
    168168
    169   // ================= Specialisation declarations
    170  
    171 //   template <> _NetworkExport void Synchronisable::registerVariable( const std::string& variable, uint8_t mode, NetworkCallbackBase *cb, bool bidirectional);
    172   template <> _NetworkExport void Synchronisable::registerVariable( std::string& variable, uint8_t mode, NetworkCallbackBase *cb, bool bidirectional);
    173   template <> _NetworkExport void Synchronisable::registerVariable( const ColourValue& variable, uint8_t mode, NetworkCallbackBase* cb, bool bidirectional);
    174   template <> _NetworkExport void Synchronisable::registerVariable( ColourValue& variable, uint8_t mode, NetworkCallbackBase* cb, bool bidirectional);
    175   template <> _NetworkExport void Synchronisable::registerVariable( const Vector2& variable, uint8_t mode, NetworkCallbackBase* cb, bool bidirectional);
    176   template <> _NetworkExport void Synchronisable::registerVariable( Vector2& variable, uint8_t mode, NetworkCallbackBase* cb, bool bidirectional);
    177   template <> _NetworkExport void Synchronisable::registerVariable( const Vector3& variable, uint8_t mode, NetworkCallbackBase* cb, bool bidirectional);
    178   template <> _NetworkExport void Synchronisable::registerVariable( Vector3& variable, uint8_t mode, NetworkCallbackBase* cb, bool bidirectional);
    179   template <> _NetworkExport void Synchronisable::registerVariable( const Vector4& variable, uint8_t mode, NetworkCallbackBase* cb, bool bidirectional);
    180   template <> _NetworkExport void Synchronisable::registerVariable( Vector4& variable, uint8_t mode, NetworkCallbackBase* cb, bool bidirectional);
    181   template <> _NetworkExport void Synchronisable::registerVariable( mbool& variable, uint8_t mode, NetworkCallbackBase* cb, bool bidirectional);
    182   template <> _NetworkExport void Synchronisable::registerVariable( const Quaternion& variable, uint8_t mode, NetworkCallbackBase* cb, bool bidirectional);
    183   template <> _NetworkExport void Synchronisable::registerVariable( Quaternion& variable, uint8_t mode, NetworkCallbackBase* cb, bool bidirectional);
    184  
    185169  template <class T> void Synchronisable::registerVariable(T& variable, uint8_t mode, NetworkCallbackBase *cb, bool bidirectional)
    186170  {
    187171    if (bidirectional)
    188172    {
    189       syncList.push_back(new SynchronisableVariableBidirectional<const T>(variable, mode, cb));
     173      syncList.push_back(new SynchronisableVariableBidirectional<T>(variable, mode, cb));
    190174      this->dataSize_ += syncList.back()->getSize(state_);
    191175    }
    192176    else
    193177    {
    194       syncList.push_back(new SynchronisableVariable<const T>(variable, mode, cb));
     178      syncList.push_back(new SynchronisableVariable<T>(variable, mode, cb));
    195179      if ( this->state_ == mode )
    196180        this->dataSize_ += syncList.back()->getSize(state_);
    197181    }
    198182  }
    199  
     183
     184  template <> _NetworkExport void Synchronisable::registerVariable( std::string& variable, uint8_t mode, NetworkCallbackBase *cb, bool bidirectional);
    200185
    201186
    202 //   template <class T> void Synchronisable::unregisterVariable(T& var){
    203 //     std::vector<SynchronisableVariableBase*>::iterator it = syncList.begin();
    204 //     while(it!=syncList.end()){
    205 //       if( ((*it)->getReference()) == &var ){
    206 //         delete (*it);
    207 //         syncList.erase(it);
    208 //         return;
    209 //       }
    210 //       else
    211 //         it++;
    212 //     }
    213 //     bool unregistered_nonexistent_variable = false;
    214 //     assert(unregistered_nonexistent_variable); //if we reach this point something went wrong:
    215 //     // the variable has not been registered before
    216 //   }
    217 
    218  
    219187}
    220188
  • code/trunk/src/libraries/network/synchronisable/SynchronisableVariable.h

    r5781 r6417  
    3535#include <cassert>
    3636#include <cstring>
    37 #include "util/Serialise.h"
     37#include "Serialise.h"
    3838#include "util/TypeTraits.h"
    3939#include "core/GameMode.h"
     
    4141
    4242namespace orxonox{
    43  
     43
    4444  namespace VariableDirection{
    4545    enum Value{
     
    5454    };
    5555  }
    56  
     56
    5757  class _NetworkExport SynchronisableVariableBase
    5858  {
     
    8181      virtual inline void* getReference(){ return static_cast<void*>(const_cast<typename Loki::TypeTraits<T>::UnqualifiedType*>(&this->variable_)); }
    8282    protected:
    83      
    84       T& variable_;
    85       uint8_t mode_;
    86       NetworkCallbackBase *callback_;
     83      T&                       variable_;
     84      uint8_t                  mode_;
     85      NetworkCallbackBase      *callback_;
    8786  };
    88  
     87
    8988  template <class T>
    9089  class SynchronisableVariableBidirectional: public SynchronisableVariable<T>
     
    9392      SynchronisableVariableBidirectional(T& variable, uint8_t master=Bidirectionality::ServerMaster, NetworkCallbackBase *cb=0);
    9493      virtual ~SynchronisableVariableBidirectional();
    95      
     94
    9695      virtual inline uint8_t getMode(){ return 0x3; } //this basically is a hack ^^
    9796      virtual inline uint32_t getData(uint8_t*& mem, uint8_t mode);
     
    113112    }
    114113  }
    115  
     114
    116115  template <class T> SynchronisableVariable<T>::~SynchronisableVariable()
    117116  {
    118     if (this->callback_ != 0)
     117    if (this->callback_)
    119118    {
    120119      NetworkCallbackManager::deleteCallback(this->callback_); //safe call for deletion
     
    141140      return;
    142141  // check whether we need to consider a callback
    143     if ( this->callback_ != 0 )
    144     {
    145       if( forceCallback || !checkEquality( this->variable_, mem ) )
    146         callback = true;
     142    if ( this->callback_ )
     143    {
     144      callback = forceCallback || !checkEquality( this->variable_, mem );
     145    }
     146  // now do a callback if neccessary
     147    if ( callback )
     148    {
     149      NetworkCallbackManager::triggerCallback( this->callback_ );
    147150    }
    148151  // write the data
    149152    loadAndIncrease( this->variable_, mem );
    150   // now do a callback if neccessary
    151     if ( callback )
    152       NetworkCallbackManager::triggerCallback( this->callback_ );
    153153  }
    154154
     
    216216            mem += sizeof(varReference_);
    217217            memcpy(static_cast<void*>(const_cast<typename Loki::TypeTraits<T>::UnqualifiedType*>(&this->varBuffer_)), &this->variable_, sizeof(T));
    218             if ( this->callback_ != 0 )
     218            if ( this->callback_ )
    219219              callback = true;
    220220          }
     
    235235          {
    236236            // value changed so remark for callback
    237             if ( this->callback_ != 0 )
     237            if ( this->callback_ )
    238238              callback = true;
    239239          }
    240240        }
    241241      }
     242  // now do a callback if neccessary
     243      if ( callback )
     244      {
     245        NetworkCallbackManager::triggerCallback( this->callback_ );
     246      }
    242247  // now write the data
    243248      loadAndIncrease(this->variable_, mem);
    244   // now do a callback if neccessary
    245       if ( callback )
    246         NetworkCallbackManager::triggerCallback( this->callback_ );
    247249    }
    248250
     
    251253      return returnSize( this->variable_ ) + sizeof(varReference_);
    252254    }
    253  
     255
    254256
    255257}
Note: See TracChangeset for help on using the changeset viewer.