Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 7512 in orxonox.OLD for branches/network/src


Ignore:
Timestamp:
May 3, 2006, 2:53:30 PM (19 years ago)
Author:
patrick
Message:

network: just modified the comments

File:
1 edited

Legend:

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

    r7508 r7512  
    4949    this->setUniqueID(SharedNetworkData::getInstance()->getNewUniqueID());
    5050  }
    51  
     51
    5252  this->registerVar( new SynchronizeableString( &this->objectName, &this->objectName, "objectName" ) );
    5353}
     
    101101  if ( sentStates.size() <= userId )
    102102    sentStates.resize( userId+1 );
    103  
     103
    104104  //calculate needed memory
    105105  int neededSize = 0;
    106  
     106
    107107  for ( SyncVarList::iterator it = syncVarList.begin(); it != syncVarList.end(); it++ )
    108108    neededSize += (*it)->getSize();
    109  
     109
    110110  assert( neededSize <= maxLength );
    111  
     111
    112112  //remove older states from history than fromStateId
    113113  StateHistory::iterator it = sentStates[userId].begin();
    114  
     114
    115115  while ( it != sentStates[userId].end() && (*it)->stateId < fromStateId )
    116116    it++;
    117  
     117
    118118  if ( it != sentStates[userId].begin() )
    119119  {
     
    128128    sentStates[userId].erase( sentStates[userId].begin(), it );
    129129  }
    130  
     130
    131131  //find state to create diff from
    132132  StateHistoryEntry * stateFrom = NULL;
    133  
     133
    134134  it = sentStates[userId].begin();
    135135  while ( it != sentStates[userId].end() && (*it)->stateId != fromStateId )
    136136    it++;
    137  
     137
    138138  if ( it == sentStates[userId].end() )
    139139  {
    140140    StateHistoryEntry * initialEntry = new StateHistoryEntry();
    141    
     141
    142142    initialEntry->stateId = fromStateId;
    143143    initialEntry->dataLength = 0;
    144144    initialEntry->data = NULL;
    145    
     145
    146146    stateFrom = initialEntry;
    147147  }
    148148  else
    149149    stateFrom = (*it);
    150  
     150
    151151  StateHistoryEntry * stateTo = new StateHistoryEntry();
    152    
     152
    153153  stateTo->stateId = stateId;
    154154  stateTo->dataLength = neededSize;
    155155  stateTo->data = (byte*)malloc( neededSize );
    156  
     156
    157157  std::list<int>::iterator sizeIter = stateFrom->sizeList.begin();
    158  
     158
    159159  int i = 0;
    160160  int n;
    161  
     161
    162162  for ( SyncVarList::iterator it = syncVarList.begin(); it != syncVarList.end(); it++ )
    163163  {
     
    178178      stateTo->sizeList.push_back( (*sizeIter) );
    179179    }
    180    
     180
    181181    if ( sizeIter != stateFrom->sizeList.end() )
    182182      sizeIter++;
    183183  }
    184  
     184
    185185  sentStates[userId].push_back( stateTo );
    186  
     186
    187187  //write diff to data
    188188  for ( i = 0; i<neededSize; i++ )
     
    193193      data[i] = stateTo->data[i];
    194194  }
    195  
     195
    196196  return neededSize;
    197197}
     
    203203 * @param length length of diff
    204204 * @param stateId id of current state
     205 * @param fromStateId id of the base state id
    205206 * @return true on success
    206207 */
     
    210211  if ( recvStates.size() <= userId )
    211212    recvStates.resize( userId+1 );
    212  
     213
    213214  //create new state
    214215  StateHistoryEntry * stateTo = new StateHistoryEntry();
     
    216217  stateTo->dataLength = length;
    217218  stateTo->data = (byte*)malloc( length );
    218  
    219   //remove old states 
     219
     220  //remove old states
    220221  StateHistory::iterator it = recvStates[userId].begin();
    221  
     222
    222223  while ( it != recvStates[userId].end() && (*it)->stateId < fromStateId )
    223224    it++;
    224  
     225
    225226  if ( it != recvStates[userId].begin() )
    226227  {
     
    235236    recvStates[userId].erase( recvStates[userId].begin(), it );
    236237  }
    237  
     238
    238239  //find state to apply diff to
    239240  StateHistoryEntry * stateFrom = NULL;
    240  
     241
    241242  it = recvStates[userId].begin();
    242243  while ( it != recvStates[userId].end() && (*it)->stateId != fromStateId )
    243244    it++;
    244  
     245
    245246  if ( it == recvStates[userId].end() )
    246247  {
    247248    StateHistoryEntry * initialEntry = new StateHistoryEntry();
    248    
     249
    249250    initialEntry->stateId = fromStateId;
    250251    initialEntry->dataLength = 0;
    251252    initialEntry->data = NULL;
    252    
     253
    253254    stateFrom = initialEntry;
    254255  }
    255256  else
    256257    stateFrom = (*it);
    257  
     258
    258259  //apply diff
    259260  for ( int i = 0; i<length; i++ )
     
    264265      stateTo->data[i] = data[i];
    265266  }
    266  
     267
    267268  //add state to state history
    268269  recvStates[userId].push_back( stateTo );
    269  
    270   int i = 0; 
    271  
     270
     271  int i = 0;
     272
    272273  for ( SyncVarList::iterator it = syncVarList.begin(); it != syncVarList.end(); it++ )
    273274  {
    274275    i += (*it)->readFromBuf( stateTo->data + i, stateTo->dataLength - i );
    275276  }
    276  
     277
    277278  assert( i == length -1 );
    278  
     279
    279280  return length;
    280281}
Note: See TracChangeset for help on using the changeset viewer.