Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
May 26, 2009, 9:20:57 PM (15 years ago)
Author:
landauf
Message:

merged netp3 branch back to trunk

Location:
code/trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • code/trunk

  • code/trunk/src/network/packet/Gamestate.cc

    r2896 r3084  
    2121 *
    2222 *   Author:
    23  *      Oliver Scheuss, (C) 2008
     23 *      Oliver Scheuss
    2424 *   Co-authors:
    2525 *      ...
     
    107107  for(it = ObjectList<Synchronisable>::begin(); it; ++it){
    108108   
    109     tempsize=it->getSize(id, mode);
     109//     tempsize=it->getSize(id, mode);
     110
     111    tempsize = it->getData(mem, id, mode);
     112    if ( tempsize != 0 )
     113      dataVector_.push_back( obj(it->getObjectID(), it->getCreatorID(), tempsize, mem-data_) );
     114   
    110115#ifndef NDEBUG
    111116    if(currentsize+tempsize > size){
     
    123128    }// stop allocate additional memory
    124129#endif
    125 
    126     if ( it->doSync( id, mode ) )
    127       dataMap_.push_back( obj(it->getObjectID(), it->getCreatorID(), tempsize, mem-data_) );
    128     if(!it->getData(mem, id, mode))
    129       return false; // mem pointer gets automatically increased because of call by reference
     130//     if(!it->getData(mem, id, mode))
     131//       return false; // mem pointer gets automatically increased because of call by reference
    130132    // increase size counter by size of current synchronisable
    131133    currentsize+=tempsize;
     
    177179    }
    178180  }
    179 
    180181   // In debug mode, check first, whether there are no duplicate objectIDs
    181182#ifndef NDEBUG
    182   ObjectList<Synchronisable>::iterator it;
    183   for (it = ObjectList<Synchronisable>::begin(); it != ObjectList<Synchronisable>::end(); ++it) {
    184     if (it->getObjectID() == OBJECTID_UNKNOWN) {
    185       if (it->objectMode_ != 0x0) {
    186         COUT(0) << "Found object with OBJECTID_UNKNOWN on the client with objectMode != 0x0!" << std::endl;
    187         COUT(0) << "Possible reason for this error: Client created a synchronized object without the Server's approval." << std::endl;
    188         COUT(0) << "Objects class: " << it->getIdentifier()->getName() << std::endl;
    189         assert(false);
     183  if(this->getID()%1000==0){
     184    std::list<uint32_t> v1;
     185    ObjectList<Synchronisable>::iterator it;
     186    for (it = ObjectList<Synchronisable>::begin(); it != ObjectList<Synchronisable>::end(); ++it) {
     187      if (it->getObjectID() == OBJECTID_UNKNOWN) {
     188        if (it->objectMode_ != 0x0) {
     189          COUT(0) << "Found object with OBJECTID_UNKNOWN on the client with objectMode != 0x0!" << std::endl;
     190          COUT(0) << "Possible reason for this error: Client created a synchronized object without the Server's approval." << std::endl;
     191          COUT(0) << "Objects class: " << it->getIdentifier()->getName() << std::endl;
     192          assert(false);
     193        }
    190194      }
    191     }
    192     else {
    193       ObjectList<Synchronisable>::iterator it2;
    194       for (it2 = ObjectList<Synchronisable>::begin(); it2 != ObjectList<Synchronisable>::end(); ++it2) {
    195         if (it->getObjectID() == it2->getObjectID() && *it != *it2) {
    196            COUT(0) << "Found duplicate objectIDs on the client!" << std::endl
    197                    << "Are you sure you don't create a Sychnronisable objcect with 'new' \
    198                        that doesn't have objectMode = 0x0?" << std::endl;
    199            assert(false);
     195      else {
     196        std::list<uint32_t>::iterator it2;
     197        for (it2 = v1.begin(); it2 != v1.end(); ++it2) {
     198          if (it->getObjectID() == *it2) {
     199            COUT(0) << "Found duplicate objectIDs on the client!" << std::endl
     200                    << "Are you sure you don't create a Sychnronisable objcect with 'new' \
     201                        that doesn't have objectMode = 0x0?" << std::endl;
     202            assert(false);
     203          }
    200204        }
     205        v1.push_back(it->getObjectID());
    201206      }
    202207    }
     
    221226  uint8_t *d1 = data_+GamestateHeader::getSize();
    222227  uint8_t *d2 = gs.data_+GamestateHeader::getSize();
     228  GamestateHeader* h1 = new GamestateHeader(data_);
     229  GamestateHeader* h2 = new GamestateHeader(gs.data_);
     230  assert(h1->getDataSize() == h2->getDataSize());
    223231  assert(!isCompressed());
    224232  assert(!gs.isCompressed());
    225   while(d1<data_+header_->getDataSize())
    226   {
    227     if(*d1!=*d2)
    228       return false;
    229     d1++;
    230     d2++;
    231   }
    232   return true;
     233  return memcmp(d1, d2, h1->getDataSize())==0;
    233234}
    234235
     
    357358}
    358359
     360// Gamestate *Gamestate::diff(Gamestate *base)
     361// {
     362//   assert(data_);
     363//   assert(!header_->isCompressed());
     364//   assert(!header_->isDiffed());
     365//   GamestateHeader diffHeader(base->data_);
     366//   uint8_t *basep = GAMESTATE_START(base->data_), *gs = GAMESTATE_START(this->data_);
     367//   uint32_t of=0; // pointers offset
     368//   uint32_t dest_length=0;
     369//   dest_length=header_->getDataSize();
     370//   if(dest_length==0)
     371//     return NULL;
     372//   uint8_t *ndata = new uint8_t[dest_length*sizeof(uint8_t)+GamestateHeader::getSize()];
     373//   uint8_t *dest = ndata + GamestateHeader::getSize();
     374//   
     375//   
     376//   // LOOP-UNROLLED DIFFING
     377//   uint32_t *dest32 = (uint32_t*)dest, *base32 = (uint32_t*)basep, *gs32 = (uint32_t*)gs;
     378//   // diff in 4-byte steps
     379//   while( of < (uint32_t)(header_->getDataSize())/4 ){
     380//     if( of < (uint32_t)(diffHeader.getDataSize())/4 )
     381//     {
     382//       *(dest32+of)=*(base32+of) ^ *(gs32+of); // do the xor
     383//       ++of;
     384//     }
     385//     else
     386//     {
     387//       *(dest32+of)=*(gs32+of); // same as 0 ^ *(gs32+of)
     388//       ++of;
     389//     }
     390//   }
     391//   for( unsigned int of2 = 0; of2 < header_->getDataSize()%4; ++of2 )
     392//   {
     393//     if( of*4+of2 < diffHeader.getDataSize() )
     394//     {
     395//       *(dest+4*of+of2)=*(basep+4*of+of2) ^ *(gs+4*of+of2); // do the xor
     396//     }
     397//     else
     398//     {
     399//       *(dest+4*of+of2)=*(gs+4*of+of2); // same as 0 ^ *(gs32+of)
     400//     }
     401//   }
     402//
     403//   Gamestate *g = new Gamestate(ndata, getClientID());
     404//   *(g->header_) = *header_;
     405//   g->header_->setDiffed( true );
     406//   g->header_->setBaseID( base->getID() );
     407//   g->flags_=flags_;
     408//   g->packetDirection_ = packetDirection_;
     409//   return g;
     410// }
     411
    359412Gamestate* Gamestate::doSelection(unsigned int clientID, unsigned int targetSize){
    360413  assert(data_);
     
    378431
    379432  //call TrafficControl
    380   TrafficControl::getInstance()->processObjectList( clientID, header_->getID(), &dataMap_ );
     433  TrafficControl::getInstance()->processObjectList( clientID, header_->getID(), dataVector_ );
    381434
    382435  //copy in the zeros
    383   for(it=dataMap_.begin(); it!=dataMap_.end();){
     436//   std::list<obj>::iterator itt;
     437//   COUT(0) << "myvector contains:";
     438//   for ( itt=dataVector_.begin() ; itt!=dataVector_.end(); itt++ )
     439//     COUT(0) << " " << (*itt).objID;
     440//   COUT(0) << endl;
     441  for(it=dataVector_.begin(); it!=dataVector_.end();){
    384442    SynchronisableHeader oldobjectheader(origdata);
    385443    SynchronisableHeader newobjectheader(newdata);
Note: See TracChangeset for help on using the changeset viewer.