Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 8623 in orxonox.OLD for trunk/src/lib/network/synchronizeable.cc


Ignore:
Timestamp:
Jun 20, 2006, 1:39:01 PM (19 years ago)
Author:
bensch
Message:

orxonox/trunk: merged the network branche back here
merged with command:
svn merge -r8230:HEAD https://svn.orxonox.net/orxonox/branches/network .
conflicts resolved in favour of the network branche (conflicts were in network)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/lib/network/synchronizeable.cc

    r8228 r8623  
    7070    this->networkStream->disconnectSynchronizeable(*this);
    7171 
    72   if ( this->isServer() && this->beSynchronized() && this->getUniqueID() > 0 )
     72  if ( this->isServer() && this->beSynchronized() && this->getUniqueID() > 0 && !this->isA( CL_MESSAGE_MANAGER ) )
    7373    NetworkGameManager::getInstance()->removeSynchronizeable( this->getUniqueID() );
     74   
     75  for ( SyncVarList::iterator it = syncVarList.begin(); it != syncVarList.end(); it++ )
     76  {
     77    delete *it;
     78  }
     79  syncVarList.clear();
     80 
     81  for ( UserStateHistory::iterator it = recvStates.begin(); it != recvStates.end(); it++ )
     82  {
     83    for ( StateHistory::iterator it2 = it->begin(); it2 != it->end(); it2++ )
     84    {
     85      if ( (*it2)->data )
     86      {
     87        delete [] (*it2)->data;
     88        (*it2)->data = NULL;
     89      }
     90      delete *it2;
     91    }
     92
     93  }
     94 
     95  for ( UserStateHistory::iterator it = sentStates.begin(); it != sentStates.end(); it++ )
     96  {
     97    for ( StateHistory::iterator it2 = it->begin(); it2 != it->end(); it2++ )
     98    {
     99      if ( (*it2)->data )
     100      {
     101        delete [] (*it2)->data;
     102        (*it2)->data = NULL;
     103      }
     104      delete *it2;
     105    }
     106
     107  }
    74108}
    75109
     
    134168        (*it2)->data = NULL;
    135169      }
     170     
     171      delete *it2;
    136172    }
    137173    sentStates[userId].erase( sentStates[userId].begin(), it );
     
    159195
    160196    stateFrom = initialEntry;
     197   
     198    sentStates[userId].push_back( stateFrom );
    161199  }
    162200  else
    163201    stateFrom = (*it);
    164202
    165   StateHistoryEntry * stateTo = new StateHistoryEntry();
    166 
     203  StateHistoryEntry * stateTo = new StateHistoryEntry;
     204
     205  sentStates[userId].push_back( stateTo );
     206 
    167207  stateTo->stateId = stateId;
    168208  stateTo->dataLength = neededSize;
     
    175215 
    176216  bool hasPermission;
     217  bool sizeChanged = false;
    177218
    178219  // now do the actual synchronization: kick all variables to write into a common buffer
     
    186227                    );
    187228   
    188     if ( ( sizeIter != stateFrom->sizeList.end() && *sizeIter != (*it)->getSize() ) || ( hasPermission && (*it)->getPriority() >= priorityTH ) || sizeIter == stateFrom->sizeList.end() )
     229    if ( sizeIter == stateFrom->sizeList.end() || *sizeIter != (*it)->getSize() )
     230      sizeChanged = true;
     231   
     232    if ( ( hasPermission && (*it)->getPriority() >= priorityTH ) || sizeChanged )
    189233    {
    190234      n = (*it)->writeToBuf( stateTo->data+i, stateTo->dataLength - i );
     
    210254  }
    211255
    212   sentStates[userId].push_back( stateTo );
    213  
    214256  if ( i != neededSize )
    215257  {
     
    275317
    276318    stateFrom = initialEntry;
     319   
     320    recvStates[userId].push_back( stateFrom );
    277321  }
    278322  else
     
    374418    {
    375419      if ( (*it)->data )
     420      {
    376421        delete [] (*it)->data;
    377       (*it)->data = NULL;
     422        (*it)->data = NULL;
     423      }
    378424   
    379425      delete *it;
     
    388434    {
    389435      if ( (*it)->data )
     436      {
    390437        delete [] (*it)->data;
    391       (*it)->data = NULL;
     438        (*it)->data = NULL;
     439      }
    392440   
    393441      delete *it;
     
    438486     
    439487      if ( (*delIt)->data )
     488      {
    440489        delete [] (*delIt)->data;
     490        (*delIt)->data = NULL;
     491      }
     492      delete *delIt;
    441493      recvStates[userId].erase( delIt );
    442494     
     
    506558     
    507559      if ( (*delIt)->data )
     560      {
    508561        delete [] (*delIt)->data;
     562        (*delIt)->data = NULL;
     563      }
     564      delete *delIt;
    509565      sentStates[userId].erase( delIt );
    510566     
Note: See TracChangeset for help on using the changeset viewer.