Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Oct 29, 2008, 5:19:02 PM (16 years ago)
Author:
scheusso
Message:

client→server synchronisation of controllable entities works now

Location:
code/branches/objecthierarchy/src
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • code/branches/objecthierarchy/src/network/Synchronisable.cc

    r2041 r2062  
    147147    synchronisableHeader *header = (synchronisableHeader *)mem;
    148148
     149    if(!header->dataAvailable)
     150    {
     151      mem += header->size;
     152      return 0;
     153    }
     154   
    149155    COUT(4) << "fabricating object with id: " << header->objectID << std::endl;
    150156
     
    314320      }
    315321      // if the variable gets synchronised bidirectional, then add the reference to the bytestream
    316       if( ( (*i)->mode & direction::bidirectional ) )
     322      if( ( (*i)->mode & direction::bidirectional ) == direction::bidirectional )
    317323      {
    318324        *(uint8_t*)mem = (*i)->varReference;
    319325        mem += sizeof( (*i)->varReference );
     326        tempsize += sizeof( (*i)->varReference );
    320327      }
    321328      switch((*i)->type){
     
    323330          memcpy( (void *)(mem), (void*)((*i)->var), (*i)->size);
    324331          mem+=(*i)->size;
    325           tempsize+=(*i)->size + sizeof( (*i)->varReference );
     332          tempsize+=(*i)->size;
    326333          break;
    327334        case STRING:
     
    332339          COUT(5) << "synchronisable: char: " << (const char *)(mem) << " data: " << data << " string: " << *(std::string *)((*i)->var) << std::endl;
    333340          mem+=(*i)->size;
    334           tempsize+=(*i)->size + sizeof( (*i)->varReference ) + sizeof(size_t);
     341          tempsize+=(*i)->size + sizeof(size_t);
    335342          break;
    336343      }
     
    381388      switch((*i)->type){
    382389        case DATA:
    383           if( ( (*i)->mode & direction::bidirectional ) )
     390          if( ( (*i)->mode & direction::bidirectional ) == direction::bidirectional )
    384391          {
    385392            if( ( mode == 0x1 && (*i)->mode == direction::serverMaster ) || \
     
    406413          break;
    407414        case STRING:
    408           if( ( (*i)->mode & direction::bidirectional ) )
     415          if( ( (*i)->mode & direction::bidirectional ) == direction::bidirectional )
    409416          {
    410417            if( ( mode == 0x1 && (*i)->mode == direction::serverMaster ) || \
     
    469476        break;
    470477      }
    471       if( ( (*i)->mode & direction::bidirectional ) != 0)
     478      if( ( (*i)->mode & direction::bidirectional ) == direction::bidirectional )
    472479      {
    473480        tsize+=sizeof( (*i)->varReference );
  • code/branches/objecthierarchy/src/network/packet/Gamestate.cc

    r2041 r2062  
    357357    assert(it->second->objectID==oldobjectheader->objectID);
    358358    *newobjectheader = *oldobjectheader;
    359     objectOffset=sizeof(uint8_t)+sizeof(bool); //skip the size and the availableDate variables in the objectheader
     359    objectOffset=sizeof(uint8_t)+sizeof(bool); //skip the size and the availableData variables in the objectheader
    360360    if(it->second->doSelection(HEADER->id)){
    361361      newobjectheader->dataAvailable=true; //TODO: probably not neccessary
  • code/branches/objecthierarchy/src/orxonox/objects/worldentities/ControllableEntity.cc

    r2048 r2062  
    163163            if (!Core::isMaster())
    164164            {
     165                this->client_overwrite_ = this->server_overwrite_;
    165166COUT(0) << "CE: bidirectional synchronization" << std::endl;
    166167                this->setObjectMode(network::direction::bidirectional);
     
    248249    {
    249250        REGISTERSTRING(this->cameraPositionTemplate_, network::direction::toclient);
     251       
     252       
     253        REGISTERDATA(this->client_overwrite_,   network::direction::toserver);
     254        REGISTERDATA(this->server_overwrite_,   network::direction::toclient, new network::NetworkCallback<ControllableEntity>(this, &ControllableEntity::processOverwrite));
    250255
    251256        REGISTERDATA(this->server_position_,    network::direction::toclient, new network::NetworkCallback<ControllableEntity>(this, &ControllableEntity::processServerPosition));
     
    253258        REGISTERDATA(this->server_orientation_, network::direction::toclient, new network::NetworkCallback<ControllableEntity>(this, &ControllableEntity::processServerOrientation));
    254259
    255         REGISTERDATA(this->server_overwrite_,   network::direction::toclient, new network::NetworkCallback<ControllableEntity>(this, &ControllableEntity::processOverwrite));
    256260
    257261        REGISTERDATA(this->client_position_,    network::direction::toserver, new network::NetworkCallback<ControllableEntity>(this, &ControllableEntity::processClientPosition));
     
    259263        REGISTERDATA(this->client_orientation_, network::direction::toserver, new network::NetworkCallback<ControllableEntity>(this, &ControllableEntity::processClientOrientation));
    260264
    261         REGISTERDATA(this->client_overwrite_,   network::direction::toserver);
    262265
    263266        REGISTERDATA(this->playerID_, network::direction::toclient, new network::NetworkCallback<ControllableEntity>(this, &ControllableEntity::networkcallback_changedplayerID));
     
    302305            this->server_position_ = this->client_position_;
    303306        }
     307        else
     308          COUT(2) << "callback: not setting client position" << endl;
    304309    }
    305310
     
    453458        else if (this->bControlled_)
    454459        {
    455             this->node_->lookAt(target, relativeTo, localDirectionVector);
     460//             this->node_->lookAt(target, relativeTo, localDirectionVector);
    456461            this->client_orientation_ = this->node_->getOrientation();
    457462        }
Note: See TracChangeset for help on using the changeset viewer.