Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Jul 18, 2009, 6:23:31 PM (16 years ago)
Author:
rgrieder
Message:

Merged netp6 branch back to the trunk.

Location:
code/trunk
Files:
2 deleted
21 edited

Legend:

Unmodified
Added
Removed
  • code/trunk

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

    r3214 r3304  
    3131  NetworkFunction.cc
    3232  Host.cc
    33   PacketBuffer.cc
    3433  Server.cc
    3534  ServerConnection.cc
  • code/trunk/src/network/ClientInformation.h

    r3198 r3304  
    8787    static ClientInformation *findClient(ENetAddress *address, bool look_backwards=false);
    8888    static ClientInformation *getBegin(){return head_;}
     89    static bool hasClients(){ return ClientInformation::head_!=0; }
    8990
    9091    bool setSynched(bool s);
  • code/trunk/src/network/Connection.cc

    r3214 r3304  
    3131#include <cassert>
    3232#include <enet/enet.h>
    33 #include <OgreTimer.h>
    3433#include "packet/Packet.h"
    3534
     
    7776   
    7877    assert(this->host_);
    79     Ogre::Timer timer;
    8078
    81     while( timer.getMilliseconds()<NETWORK_MAX_QUEUE_PROCESS_TIME && enet_host_service( this->host_, &event, NETWORK_WAIT_TIMEOUT ) > 0 )
     79    while( enet_host_service( this->host_, &event, NETWORK_WAIT_TIMEOUT ) > 0 )
    8280    {
    8381      switch(event.type){
  • code/trunk/src/network/GamestateClient.cc

    r3214 r3304  
    5252
    5353  GamestateClient::~GamestateClient() {
     54      std::map<unsigned int, packet::Gamestate *>::iterator it;
     55      for ( it = this->gamestateMap_.begin(); it != this->gamestateMap_.end(); ++it )
     56          delete (*it).second;
     57      if( this->tempGamestate_ )
     58          delete this->tempGamestate_;
    5459  }
    5560
  • code/trunk/src/network/GamestateClient.h

    r3301 r3304  
    7373    std::map<unsigned int, packet::Gamestate *> gamestateMap_;
    7474    packet::Gamestate *tempGamestate_; // we save the received gamestates here during processQueue
    75     unsigned char *shipCache_;
    7675
    7776  };
  • code/trunk/src/network/GamestateManager.cc

    r3301 r3304  
    4242
    4343#include <cassert>
     44#include <queue>
     45// #include <boost/thread/mutex.hpp>
    4446
    4547#include "util/Debug.h"
     48#include "core/Executor.h"
     49#include "core/ThreadPool.h"
    4650#include "ClientInformation.h"
    4751#include "packet/Acknowledgement.h"
     
    5660  {
    5761    trafficControl_ = new TrafficControl();
     62//     threadMutex_ = new boost::mutex();
     63//     threadPool_ = new ThreadPool();
    5864  }
    5965
     
    6167  {
    6268    if( this->reference )
    63       delete this->reference;
    64     for( std::map<unsigned int, packet::Gamestate*>::iterator it = gamestateQueue.begin(); it != gamestateQueue.end(); it++ )
     69        delete this->reference;std::map<unsigned int, packet::Gamestate*>::iterator it;
     70    for( it = gamestateQueue.begin(); it != gamestateQueue.end(); ++it )
    6571      delete (*it).second;
    66     delete trafficControl_;
     72    std::map<unsigned int, std::map<unsigned int, packet::Gamestate*> >::iterator it1;
     73    std::map<unsigned int, packet::Gamestate*>::iterator it2;
     74    for( it1 = gamestateMap_.begin(); it1 != gamestateMap_.end(); ++it1 )
     75    {
     76      for( it2 = it1->second.begin(); it2 != it1->second.end(); ++it2 )
     77        delete (*it2).second;
     78    }
     79    delete this->trafficControl_;
     80//     delete this->threadMutex_;
     81//     delete this->threadPool_;
    6782  }
    6883
     
    8499
    85100  bool GamestateManager::processGamestates(){
     101    if( this->gamestateQueue.empty() )
     102        return true;
    86103    std::map<unsigned int, packet::Gamestate*>::iterator it;
    87104    // now push only the most recent gamestates we received (ignore obsolete ones)
     
    109126    return true;
    110127  }
    111 
    112 
    113   packet::Gamestate *GamestateManager::popGameState(unsigned int clientID) {
     128 
     129  void GamestateManager::sendGamestates()
     130  {
     131    ClientInformation *temp = ClientInformation::getBegin();
     132    std::queue<packet::Gamestate*> clientGamestates;
     133    while(temp != NULL){
     134      if( !(temp->getSynched()) ){
     135        COUT(5) << "Server: not sending gamestate" << std::endl;
     136        temp=temp->next();
     137        if(!temp)
     138          break;
     139        continue;
     140      }
     141      COUT(4) << "client id: " << temp->getID() << " RTT: " << temp->getRTT() << " loss: " << temp->getPacketLoss() << std::endl;
     142      COUT(5) << "Server: doing gamestate gamestate preparation" << std::endl;
     143      int cid = temp->getID(); //get client id
     144     
     145      unsigned int gID = temp->getGamestateID();
     146      if(!reference)
     147        return;
     148     
     149      packet::Gamestate *client=0;
     150      if(gID != GAMESTATEID_INITIAL){
     151        assert(gamestateMap_.find(cid)!=gamestateMap_.end());
     152        std::map<unsigned int, packet::Gamestate*>::iterator it = gamestateMap_[cid].find(gID);
     153        if(it!=gamestateMap_[cid].end())
     154        {
     155          client = it->second;
     156        }
     157      }
     158     
     159      clientGamestates.push(0);
     160      finishGamestate( cid, &clientGamestates.back(), client, reference );
     161      //FunctorMember<GamestateManager>* functor =
     162//       ExecutorMember<GamestateManager>* executor = createExecutor( createFunctor(&GamestateManager::finishGamestate) );
     163//       executor->setObject(this);
     164//       executor->setDefaultValues( cid, &clientGamestates.back(), client, reference );
     165//       (*static_cast<Executor*>(executor))();
     166//       this->threadPool_->passFunction( executor, true );
     167//       (*functor)( cid, &(clientGamestates.back()), client, reference );
     168     
     169      temp = temp->next();
     170    }
     171   
     172//     threadPool_->synchronise();
     173   
     174    while( !clientGamestates.empty() )
     175    {
     176      if(clientGamestates.front())
     177        clientGamestates.front()->send();
     178      clientGamestates.pop();
     179    }
     180  }
     181
     182
     183  void GamestateManager::finishGamestate( unsigned int clientID, packet::Gamestate** destgamestate, packet::Gamestate* base, packet::Gamestate* gamestate ) {
    114184    //why are we searching the same client's gamestate id as we searched in
    115185    //Server::sendGameState?
    116     packet::Gamestate *gs;
    117     unsigned int gID = ClientInformation::findClient(clientID)->getGamestateID();
    118     if(!reference)
    119       return 0;
    120     gs = reference->doSelection(clientID, 10000);
    121186    // save the (undiffed) gamestate in the clients gamestate map
    122     gamestateMap_[clientID][gs->getID()]=gs;
    123187    //chose wheather the next gamestate is the first or not
    124     packet::Gamestate *client=0;
    125     if(gID != GAMESTATEID_INITIAL){
    126       assert(gamestateMap_.find(clientID)!=gamestateMap_.end());
    127       std::map<unsigned int, packet::Gamestate*>::iterator it = gamestateMap_[clientID].find(gID);
    128       if(it!=gamestateMap_[clientID].end())
    129       {
    130         client = it->second;
    131       }
    132     }
    133     if(client){
     188   
     189    packet::Gamestate *gs = gamestate->doSelection(clientID, 20000);
     190//     packet::Gamestate *gs = new packet::Gamestate(*gamestate);
     191//     packet::Gamestate *gs = new packet::Gamestate();
     192//     gs->collectData( id_, 0x1 );
     193//     this->threadMutex_->lock();
     194    gamestateMap_[clientID][gamestate->getID()]=gs;
     195//     this->threadMutex_->unlock();
     196   
     197    if(base)
     198    {
     199       
    134200//       COUT(3) << "diffing" << std::endl;
    135201//       packet::Gamestate* gs1  = gs;
    136       packet::Gamestate *diffed = gs->diff(client);
     202      packet::Gamestate *diffed = gs->diff(base);
    137203      //packet::Gamestate *gs2 = diffed->undiff(gs);
    138204//       assert(*gs == *gs2);
     
    143209    }
    144210    else{
    145 //       COUT(3) << "not diffing" << std::endl;
    146211      gs = new packet::Gamestate(*gs);
    147212    }
     213   
     214   
    148215    bool b = gs->compressData();
    149216    assert(b);
    150     COUT(4) << "sending gamestate with id " << gs->getID();
    151     if(gs->isDiffed())
    152     COUT(4) << " and baseid " << gs->getBaseID() << endl;
    153     else
    154     COUT(4) << endl;
    155     return gs;
     217//     COUT(4) << "sending gamestate with id " << gs->getID();
     218//     if(gamestate->isDiffed())
     219//     COUT(4) << " and baseid " << gs->getBaseID() << endl;
     220//     else
     221//     COUT(4) << endl;
     222    gs->setClientID(clientID);
     223    *destgamestate = gs;
    156224  }
    157225
     
    175243
    176244    assert(curid==GAMESTATEID_INITIAL || curid<gamestateID);
    177     COUT(4) << "acking gamestate " << gamestateID << " for clientid: " << clientID << " curid: " << curid << std::endl;
     245    COUT(5) << "acking gamestate " << gamestateID << " for clientid: " << clientID << " curid: " << curid << std::endl;
    178246    std::map<unsigned int, packet::Gamestate*>::iterator it;
    179247    for(it = gamestateMap_[clientID].begin(); it!=gamestateMap_[clientID].end() && it->first<gamestateID; ){
  • code/trunk/src/network/GamestateManager.h

    r3214 r3304  
    4545#include <map>
    4646#include "GamestateHandler.h"
     47#include "core/CorePrereqs.h"
    4748
    4849namespace orxonox
     
    7374    bool processGamestates();
    7475    bool update();
    75     packet::Gamestate *popGameState(unsigned int clientID);
     76    void sendGamestates();
     77//     packet::Gamestate *popGameState(unsigned int clientID);
     78    void finishGamestate( unsigned int clientID, packet::Gamestate** destgamestate, packet::Gamestate* base, packet::Gamestate* gamestate );
    7679
    7780    bool getSnapshot();
     
    7982    bool ack(unsigned int gamestateID, unsigned int clientID);
    8083    void removeClient(ClientInformation *client);
    81     private:
     84  private:
    8285    bool processGamestate(packet::Gamestate *gs);
    8386
    8487    std::map<unsigned int, std::map<unsigned int, packet::Gamestate*> > gamestateMap_;
    85     //std::map<int, packet::Gamestate*> gamestateMap; //map gsID to gamestate*
    86     //std::map<int, int> gamestateUsed; // save the number of clients, that use the specific gamestate
    8788    std::map<unsigned int, packet::Gamestate*> gamestateQueue;
    8889    packet::Gamestate *reference;
    8990    TrafficControl *trafficControl_;
    9091    unsigned int id_;
     92//     boost::mutex* threadMutex_;
     93    ThreadPool*   /*thread*/Pool_;
    9194  };
    9295
  • code/trunk/src/network/Host.cc

    r3214 r3304  
    7474}
    7575
    76 
    77 // bool Host::chat(std::string& message){
    78 //   if(!instance_)
    79 //     return false;
    80 //   packet::Chat *c = new packet::Chat(message, getPlayerID());
    81 //   return instance_->sendChat(c);
    82 // }
    83 
    84 // bool Host::receiveChat(packet::Chat *message, unsigned int clientID){
    85 //   if(instance_)
    86 //     return instance_->processChat(message, clientID);
    87 //   else
    88 //     return false;
    89 // }
    90 
    9176/**
    9277 * This function returns the ID of the player
  • code/trunk/src/network/NetworkFunction.cc

    r3214 r3304  
    5656 
    5757 
     58  void NetworkFunctionBase::destroyAllNetworkFunctions()
     59  {
     60    std::map<std::string, NetworkFunctionBase*>::iterator it;
     61    for( it=NetworkFunctionBase::nameMap_.begin(); it!=NetworkFunctionBase::nameMap_.end(); ++it )
     62      delete it->second;
     63  }
     64 
    5865 
    5966  NetworkFunctionStatic::NetworkFunctionStatic(FunctorStatic* functor, const std::string& name, const NetworkFunctionPointer& p):
  • code/trunk/src/network/NetworkFunction.h

    r3214 r3304  
    3737#include <string>
    3838#include <boost/preprocessor/cat.hpp>
     39#include <boost/static_assert.hpp>
    3940
    4041#include "core/OrxonoxClass.h"
     
    4647{
    4748
    48 #ifdef ORXONOX_COMPILER_GCC
     49#if defined(ORXONOX_COMPILER_GCC) && defined(ORXONOX_ARCH_32)
    4950static const unsigned int MAX_FUNCTION_POINTER_SIZE = 8;
    50 #else //ORXONOX_COMPILER_GCC
     51#else
    5152static const unsigned int MAX_FUNCTION_POINTER_SIZE = 16;
    5253#endif //ORXONOX_COMPILER_GCC
     
    5758  bool operator<(const NetworkFunctionPointer& b) const
    5859  {
    59 #ifdef ORXONOX_COMPILER_GCC
     60#if defined(ORXONOX_COMPILER_GCC) && defined(ORXONOX_ARCH_32)
    6061    return pointer[0]<b.pointer[0] ? true : pointer[1]<b.pointer[1];
    6162#else //ORXONOX_COMPILER_GCC
     
    8081   
    8182    static inline void setNetworkID(const std::string& name, uint32_t id){ assert( nameMap_.find(name)!=nameMap_.end() ); nameMap_[name]->setNetworkID(id); }
     83   
     84    static void destroyAllNetworkFunctions();
    8285   
    8386  protected:
     
    193196template<class T> inline void copyPtr( T ptr, NetworkFunctionPointer& destptr)
    194197{
    195   memset((uint8_t*)&destptr + sizeof(T), 0, sizeof(NetworkFunctionPointer)-sizeof(T));
     198  if( sizeof(NetworkFunctionPointer)-sizeof(T) > 0)
     199    memset((uint8_t*)&destptr + sizeof(T), 0, sizeof(NetworkFunctionPointer)-sizeof(T));
    196200  T p2 = ptr;
    197201  memcpy( &destptr, &p2, sizeof(T) );
     
    202206template<class T> inline void* registerStaticNetworkFunctionFct( T ptr, const std::string& name )
    203207{
     208  BOOST_STATIC_ASSERT( sizeof(T)<=sizeof(NetworkFunctionPointer) ); // if this fails your compiler uses bigger pointers for static functions than defined above
    204209  NetworkFunctionPointer destptr;
    205210  copyPtr( ptr, destptr );
     
    210215template<class T, class PT> inline void* registerMemberNetworkFunctionFct( PT ptr, const std::string& name )
    211216{
     217  BOOST_STATIC_ASSERT( sizeof(PT)<=sizeof(NetworkFunctionPointer) ); // if this fails your compiler uses bigger pointers for a specific kind of member functions than defined above
    212218  NetworkFunctionPointer destptr;
    213219  copyPtr( ptr, destptr );
  • code/trunk/src/network/NetworkPrereqs.h

    r3301 r3304  
    102102  template <class T> class NetworkMemeberFunction;
    103103  struct NetworkFunctionPointer;
    104   class PacketBuffer;
    105104  class Server;
    106105  class ServerConnection;
  • code/trunk/src/network/Server.cc

    r3214 r3304  
    4848#include "core/Clock.h"
    4949#include "core/ObjectList.h"
     50#include "core/Executor.h"
    5051#include "packet/Chat.h"
    5152#include "packet/ClassID.h"
     
    6869  */
    6970  Server::Server() {
    70     timeSinceLastUpdate_=0;
    71     gamestates_ = new GamestateManager();
     71    this->timeSinceLastUpdate_=0;
    7272  }
    7373
    7474  Server::Server(int port){
    7575    this->setPort( port );
    76     timeSinceLastUpdate_=0;
    77     gamestates_ = new GamestateManager();
     76    this->timeSinceLastUpdate_=0;
    7877  }
    7978
     
    8685    this->setPort( port );
    8786    this->setBindAddress( bindAddress );
    88     timeSinceLastUpdate_=0;
    89     gamestates_ = new GamestateManager();
     87    this->timeSinceLastUpdate_=0;
    9088  }
    9189
     
    9492  */
    9593  Server::~Server(){
    96     if(gamestates_)
    97       delete gamestates_;
    9894  }
    9995
     
    138134  */
    139135  void Server::update(const Clock& time) {
     136    // receive incoming packets
    140137    Connection::processQueue();
    141     gamestates_->processGamestates();
    142     //this steers our network frequency
    143     timeSinceLastUpdate_+=time.getDeltaTime();
    144     if(timeSinceLastUpdate_>=NETWORK_PERIOD)
     138   
     139    if ( ClientInformation::hasClients() )
    145140    {
    146       timeSinceLastUpdate_ -= static_cast<unsigned int>( timeSinceLastUpdate_ / NETWORK_PERIOD ) * NETWORK_PERIOD;
    147       updateGamestate();
     141      // process incoming gamestates
     142      GamestateManager::processGamestates();
     143     
     144      // send function calls to clients
    148145      FunctionCallManager::sendCalls();
    149     }
    150     sendPackets(); // flush the enet queue
     146     
     147      //this steers our network frequency
     148      timeSinceLastUpdate_+=time.getDeltaTime();
     149      if(timeSinceLastUpdate_>=NETWORK_PERIOD)
     150      {
     151        timeSinceLastUpdate_ -= static_cast<unsigned int>( timeSinceLastUpdate_ / NETWORK_PERIOD ) * NETWORK_PERIOD;
     152        updateGamestate();
     153      }
     154      sendPackets(); // flush the enet queue
     155    }
    151156  }
    152157
     
    175180  */
    176181  void Server::updateGamestate() {
    177 //     if( ClientInformation::getBegin()==NULL )
     182    if( ClientInformation::getBegin()==NULL )
    178183      //no client connected
    179 //       return;
    180     gamestates_->update();
     184      return;
     185    GamestateManager::update();
    181186    COUT(5) << "Server: one gamestate update complete, goig to sendGameState" << std::endl;
    182187    //std::cout << "updated gamestate, sending it" << std::endl;
     
    197202  */
    198203  bool Server::sendGameState() {
    199     COUT(5) << "Server: starting function sendGameState" << std::endl;
    200     ClientInformation *temp = ClientInformation::getBegin();
    201     bool added=false;
    202     while(temp != NULL){
    203       if( !(temp->getSynched()) ){
    204         COUT(5) << "Server: not sending gamestate" << std::endl;
    205         temp=temp->next();
    206         if(!temp)
    207           break;
    208         //think this works without continue
    209         continue;
    210       }
    211       COUT(4) << "client id: " << temp->getID() << " RTT: " << temp->getRTT() << " loss: " << temp->getPacketLoss() << std::endl;
    212       COUT(5) << "Server: doing gamestate gamestate preparation" << std::endl;
    213       int gid = temp->getGamestateID(); //get gamestate id
    214       int cid = temp->getID(); //get client id
    215       COUT(5) << "Server: got acked (gamestate) ID from clientlist: " << gid << std::endl;
    216       packet::Gamestate *gs = gamestates_->popGameState(cid);
    217       if(gs==NULL){
    218         COUT(2) << "Server: could not generate gamestate (NULL from compress)" << std::endl;
    219         temp = temp->next();
    220         continue;
    221       }
    222       //std::cout << "adding gamestate" << std::endl;
    223       gs->setClientID(cid);
    224       if ( !gs->send() ){
    225         COUT(3) << "Server: packet with client id (cid): " << cid << " not sended: " << temp->getFailures() << std::endl;
    226         temp->addFailure();
    227       }else
    228         temp->resetFailures();
    229       added=true;
    230       temp=temp->next();
    231       // gs gets automatically deleted by enet callback
    232     }
     204//     COUT(5) << "Server: starting function sendGameState" << std::endl;
     205//     ClientInformation *temp = ClientInformation::getBegin();
     206//     bool added=false;
     207//     while(temp != NULL){
     208//       if( !(temp->getSynched()) ){
     209//         COUT(5) << "Server: not sending gamestate" << std::endl;
     210//         temp=temp->next();
     211//         if(!temp)
     212//           break;
     213//         continue;
     214//       }
     215//       COUT(4) << "client id: " << temp->getID() << " RTT: " << temp->getRTT() << " loss: " << temp->getPacketLoss() << std::endl;
     216//       COUT(5) << "Server: doing gamestate gamestate preparation" << std::endl;
     217//       int cid = temp->getID(); //get client id
     218//       packet::Gamestate *gs = GamestateManager::popGameState(cid);
     219//       if(gs==NULL){
     220//         COUT(2) << "Server: could not generate gamestate (NULL from compress)" << std::endl;
     221//         temp = temp->next();
     222//         continue;
     223//       }
     224//       //std::cout << "adding gamestate" << std::endl;
     225//       gs->setClientID(cid);
     226//       if ( !gs->send() ){
     227//         COUT(3) << "Server: packet with client id (cid): " << cid << " not sended: " << temp->getFailures() << std::endl;
     228//         temp->addFailure();
     229//       }else
     230//         temp->resetFailures();
     231//       added=true;
     232//       temp=temp->next();
     233//       // gs gets automatically deleted by enet callback
     234//     }
     235    GamestateManager::sendGamestates();
    233236    return true;
    234237  }
     
    324327  void Server::disconnectClient( ClientInformation *client ){
    325328    ServerConnection::disconnectClient( client );
    326     gamestates_->removeClient(client);
     329    GamestateManager::removeClient(client);
    327330// inform all the listeners
    328331    ObjectList<ClientConnectionListener>::iterator listener = ObjectList<ClientConnectionListener>::begin();
  • code/trunk/src/network/Server.h

    r3214 r3304  
    3434#include "core/CorePrereqs.h"
    3535#include "Host.h"
     36#include "GamestateManager.h"
    3637#include "ServerConnection.h"
    3738
     
    4344  * It implements all functions necessary for a Server
    4445  */
    45   class _NetworkExport Server : public Host, public ServerConnection{
     46  class _NetworkExport Server : public Host, public ServerConnection, public GamestateManager{
    4647  public:
    4748    Server();
     
    6364    unsigned int shipID(){return 0;}
    6465    unsigned int playerID(){return 0;}
    65 
     66   
    6667    void addClient(ENetEvent *event);
    6768    bool createClient(int clientID);
     
    7576    void syncClassid(unsigned int clientID);
    7677
    77     GamestateManager *gamestates_;
    78 
    79 
    8078    float timeSinceLastUpdate_;
    8179  };
  • code/trunk/src/network/packet/ClassID.cc

    r3280 r3304  
    142142    classname = temp+2*sizeof(uint32_t);
    143143    id=ClassByString( std::string((const char*)classname) );
    144     COUT(0) << "processing classid: " << networkID << " name: " << classname << " id: " << id << std::endl;
     144    COUT(3) << "processing classid: " << networkID << " name: " << classname << " id: " << id << std::endl;
    145145    if(id==NULL){
    146146      COUT(0) << "Recieved a bad classname" << endl;
  • code/trunk/src/network/packet/FunctionIDs.cc

    r3280 r3304  
    132132    stringsize = *(uint32_t*)(temp+sizeof(uint32_t));
    133133    functionname = temp+2*sizeof(uint32_t);
    134     COUT(0) << "processing functionid: " << networkID << " name: " << functionname << std::endl;
     134    COUT(3) << "processing functionid: " << networkID << " name: " << functionname << std::endl;
    135135    NetworkFunctionBase::setNetworkID((const char*)functionname, networkID);
    136136    temp += 2*sizeof(uint32_t) + stringsize;
  • code/trunk/src/network/synchronisable/NetworkCallbackManager.cc

    r3214 r3304  
    4444    if (it != callbackSet_.end())
    4545    {
    46       delete (*it);
    4746      callbackSet_.erase(it);
     47      delete cb;
    4848    }
    4949  }
  • code/trunk/src/network/synchronisable/Synchronisable.cc

    r3280 r3304  
    9696      if (this->objectMode_ != 0x0 && (Host::running() && Host::isServer()))
    9797        deletedObjects_.push(objectID);
    98       // delete all Synchronisable Variables from syncList ( which are also in stringList )
    99       for(std::vector<SynchronisableVariableBase*>::iterator it = syncList.begin(); it!=syncList.end(); it++)
    100         delete (*it);
    101       syncList.clear();
    102       stringList.clear();
    103     }
     98    }
     99    // delete all Synchronisable Variables from syncList ( which are also in stringList )
     100    for(std::vector<SynchronisableVariableBase*>::iterator it = syncList.begin(); it!=syncList.end(); it++)
     101      delete (*it);
     102    syncList.clear();
     103    stringList.clear();
    104104    std::map<uint32_t, Synchronisable*>::iterator it;
    105105    it = objectMap_.find(objectID);
     
    247247      return 0;
    248248    uint32_t tempsize = 0;
     249#ifndef NDEBUG
    249250    if (this->classID==0)
    250251      COUT(3) << "classid 0 " << this->getIdentifier()->getName() << std::endl;
     252#endif
    251253
    252254    if (this->classID == static_cast<uint32_t>(-1))
  • code/trunk/src/network/synchronisable/Synchronisable.h

    r3301 r3304  
    4343#include "NetworkCallback.h"
    4444
    45 /*#define REGISTERDATA(varname, ...) \
    46     registerVariable(static_cast<void*>(&varname), sizeof(varname), DATA, __VA_ARGS__)
    47 #define REGISTERSTRING(stringname, ...) \
    48     registerVariable(&stringname, stringname.length()+1, STRING, __VA_ARGS__)*/
    4945
    5046namespace orxonox
  • code/trunk/src/network/synchronisable/SynchronisableSpecialisations.cc

    r3214 r3304  
    3838namespace orxonox{
    3939 
    40 //   template <> void Synchronisable::registerVariable( const std::string& variable, uint8_t mode, NetworkCallbackBase *cb, bool bidirectional)
    41 //   {
    42 //     if (bidirectional)
    43 //       syncList.push_back(new SynchronisableVariableBidirectional<const std::string>(variable, mode, cb));
    44 //     else
    45 //       syncList.push_back(new SynchronisableVariable<const std::string>(variable, mode, cb));
    46 //     stringList.push_back(syncList.back());
    47 //   }
    48  
    4940  template <> void Synchronisable::registerVariable( std::string& variable, uint8_t mode, NetworkCallbackBase *cb, bool bidirectional)
    5041  {
     42    SynchronisableVariableBase* sv;
    5143    if (bidirectional)
    52       syncList.push_back(new SynchronisableVariableBidirectional<const std::string>(variable, mode, cb));
     44      sv = new SynchronisableVariableBidirectional<const std::string>(variable, mode, cb);
    5345    else
    54       syncList.push_back(new SynchronisableVariable<const std::string>(variable, mode, cb));
    55     stringList.push_back(syncList.back());
     46      sv = new SynchronisableVariable<const std::string>(variable, mode, cb);
     47    syncList.push_back(sv);
     48    stringList.push_back(sv);
    5649  }
    5750 
     
    7366    registerVariable(variable.y, mode, cb, bidirectional);
    7467  }
    75 //   template <> void Synchronisable::registerVariable( Vector2& variable, uint8_t mode, NetworkCallbackBase* cb, bool bidirectional)
    76 //   {
    77 //     registerVariable( (const ColourValue&)variable, mode, cb, bidirectional);
    78 //   }
    7968 
    8069  template <> void Synchronisable::registerVariable( const Vector3& variable, uint8_t mode, NetworkCallbackBase* cb, bool bidirectional)
  • code/trunk/src/network/synchronisable/SynchronisableVariable.h

    r3301 r3304  
    117117  {
    118118    if (this->callback_ != 0)
     119    {
    119120      NetworkCallbackManager::deleteCallback(this->callback_); //safe call for deletion
     121      // this is neccessary because for example for a Vector3 all 3 components of the vector use the same callback
     122    }
    120123  }
    121124
Note: See TracChangeset for help on using the changeset viewer.