Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Dec 15, 2008, 3:14:07 PM (16 years ago)
Author:
rgrieder
Message:

Bugfix in network: When checking for other objectIDs, it was possible that within the constructor of one Synchronisable, another one was created. In the check then, both have objectID == OBJECTID_UNKNOWN because the objectID of the first object was not yet set (done after construction).

  • Moved the check to Gamestate, after ALL objects of one packet have been created.
Location:
code/branches/presentation/src/network
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • code/branches/presentation/src/network/packet/Gamestate.cc

    r2459 r2464  
    163163  }
    164164
     165   // In debug mode, check first, whether there are no duplicate objectIDs
     166#ifndef NDEBUG
     167  ObjectList<Synchronisable>::iterator it;
     168  for (it = ObjectList<Synchronisable>::begin(); it != ObjectList<Synchronisable>::end(); ++it) {
     169    if (it->getObjectID() == OBJECTID_UNKNOWN) {
     170      if (it->objectMode_ != 0x0) {
     171        COUT(0) << "Found object with OBJECTID_UNKNOWN on the client with objectMode != 0x0!" << std::endl;
     172        assert(false);
     173      }
     174    }
     175    else {
     176      ObjectList<Synchronisable>::iterator it2;
     177      for (it2 = ObjectList<Synchronisable>::begin(); it2 != ObjectList<Synchronisable>::end(); ++it2) {
     178        if (it->getObjectID() == it2->getObjectID() && *it != *it2) {
     179           COUT(0) << "Found duplicate objectIDs on the client!" << std::endl
     180                   << "Are you sure you don't create a Sychnronisable objcect with 'new' \
     181                       that doesn't have objectMode = 0x0?" << std::endl;
     182           assert(false);
     183        }
     184      }
     185    }
     186  }
     187#endif
     188
    165189  return true;
    166190}
  • code/branches/presentation/src/network/synchronisable/Synchronisable.cc

    r2459 r2464  
    8080    this->setPriority( priority::normal );
    8181
    82    
    8382    // get creator id
    84 #ifndef NDEBUG
    85     ObjectList<Synchronisable>::iterator it;
    86     for(it = ObjectList<Synchronisable>::begin(); it!=ObjectList<Synchronisable>::end(); ++it){
    87       if( it->getObjectID()==this->objectID )
    88         assert(*it==this || (it->objectID==OBJECTID_UNKNOWN && it->objectMode_==0x0));
    89     }
    90 #endif
    91 
    9283    this->creatorID = OBJECTID_UNKNOWN;
    9384
Note: See TracChangeset for help on using the changeset viewer.