Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Oct 12, 2008, 12:15:30 PM (16 years ago)
Author:
scheusso
Message:

Lots of changes:
Some fixes/hacks in objects
Changes in Gamestates and bugfixes
Removed some asserts

File:
1 edited

Legend:

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

    r1834 r1901  
    6464  Synchronisable::Synchronisable(){
    6565    RegisterRootObject(Synchronisable);
    66     static unsigned int idCounter=0;
     66    static uint32_t idCounter=0;
    6767    objectFrequency_=1;
    6868    objectMode_=0x1; // by default do not send data to server
    6969    objectID=idCounter++;
    70 //     COUT(3) << " bump +++" << objectID << " | " << &objectMap_ << std::endl;
    7170    syncList = new std::list<synchronisableVariable *>;
    7271  }
     
    8180      for(std::list<synchronisableVariable *>::iterator it = syncList->begin(); it!=syncList->end(); it++)
    8281        delete (*it)->callback;
     82      deletedObjects_.push(objectID);
     83//       COUT(3) << "destruct synchronisable +++" << objectID << " | " << classID << std::endl;
    8384//       COUT(3) << " bump ---" << objectID << " | " << &objectMap_ << std::endl;
    8485//       assert(objectMap_[objectID]->objectID==objectID);
     
    9495  bool Synchronisable::create(){
    9596    this->classID = this->getIdentifier()->getNetworkID();
    96     COUT(4) << "creating synchronisable: setting classid from " << this->getIdentifier()->getName() << " to: " << classID << std::endl;
    97    
     97//     COUT(4) << "creating synchronisable: setting classid from " << this->getIdentifier()->getName() << " to: " << classID << std::endl;
     98   
     99//     COUT(3) << "construct synchronisable +++" << objectID << " | " << classID << std::endl;
    98100//     objectMap_[objectID]=this;
    99101//     assert(objectMap_[objectID]==this);
     
    121123   * @return pointer to the newly created synchronisable
    122124   */
    123   Synchronisable *Synchronisable::fabricate(unsigned char*& mem, int mode)
     125  Synchronisable *Synchronisable::fabricate(uint8_t*& mem, int mode)
    124126  {
    125127    synchronisableHeader *header = (synchronisableHeader *)mem;
     128   
     129    COUT(3) << "fabricating object with id: " << header->objectID << std::endl;
    126130   
    127131    orxonox::Identifier* id = GetIdentifier(header->classID);
     
    134138    COUT(3) << "fabricate objectID: " << no->objectID << " classID: " << no->classID << std::endl;
    135139          // update data and create object/entity...
    136     assert(no->updateData(mem, mode));
    137     assert( no->create() );
     140    bool b = no->updateData(mem, mode);
     141    assert(b);
     142    b = no->create();
     143    assert(b);
    138144    return no;
    139145  }
     
    146152   */
    147153  bool Synchronisable::deleteObject(unsigned int objectID){
    148     assert(getSynchronisable(objectID));
     154//     assert(getSynchronisable(objectID));
     155    if(!getSynchronisable(objectID))
     156      return false;
    149157    assert(getSynchronisable(objectID)->objectID==objectID);
    150158//     delete objectMap_[objectID];
     
    222230   * @return true: if !isMyTick or if everything was successfully saved
    223231   */
    224   bool Synchronisable::getData(unsigned char*& mem, unsigned int id, int mode){
     232  bool Synchronisable::getData(uint8_t*& mem, unsigned int id, int mode){
    225233    //if this tick is we dont synchronise, then abort now
    226234    if(!isMyTick(id))
     
    232240    if(classID==0)
    233241      COUT(3) << "classid 0 " << this->getIdentifier()->getName() << std::endl;
    234     this->classID=this->getIdentifier()->getNetworkID(); // TODO: correct this
     242    assert(this->classID==this->getIdentifier()->getNetworkID());
     243//     this->classID=this->getIdentifier()->getNetworkID(); // TODO: correct this
    235244    std::list<synchronisableVariable *>::iterator i;
    236245    unsigned int size;
     
    283292   * @return true/false
    284293   */
    285   bool Synchronisable::updateData(unsigned char*& mem, int mode){
     294  bool Synchronisable::updateData(uint8_t*& mem, int mode){
    286295    if(mode==0x0)
    287296      mode=state_;
     
    291300      return false;
    292301    }
    293     unsigned char *data=mem;
     302    uint8_t *data=mem;
    294303    // start extract header
    295304    synchronisableHeader *syncHeader = (synchronisableHeader *)mem;
     
    322331          break;
    323332        case STRING:
    324           (*i)->size = *(int *)mem;
     333          (*i)->size = *(uint32_t *)mem;
    325334          COUT(5) << "string size: " << (*i)->size << std::endl;
    326335          mem+=sizeof(int);
     
    346355  * @return amount of bytes
    347356  */
    348   int Synchronisable::getSize(unsigned int id, int mode){
     357  uint32_t Synchronisable::getSize(unsigned int id, int mode){
    349358    if(!isMyTick(id))
    350359      return 0;
     
    388397   * @param mem pointer to the bytestream
    389398   */
    390   bool Synchronisable::isMyData(unsigned char* mem)
     399  bool Synchronisable::isMyData(uint8_t* mem)
    391400  {
    392401    synchronisableHeader *header = (synchronisableHeader *)mem;
Note: See TracChangeset for help on using the changeset viewer.