Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 6291 in orxonox.OLD for branches/network


Ignore:
Timestamp:
Dec 26, 2005, 1:16:13 AM (19 years ago)
Author:
rennerc
Message:

commit code which crashes my system so bensch can test it

Location:
branches/network/src/world_entities
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • branches/network/src/world_entities/terrain.cc

    r6277 r6291  
    324324  setIsOutOfSync( false );
    325325
    326   SYNCHELP_READ_BEGIN();
    327   SYNCHELP_READ_STRING( modelFileName, 1024 );
    328 
    329   if ( strcmp(modelFileName, "") )
    330     this->loadModel( modelFileName );
    331 
     326  WorldEntity::writeState(data, length, sender);
    332327}
    333328
     
    345340    *reciever = rec;
    346341
    347     SYNCHELP_WRITE_BEGIN();
    348     SYNCHELP_WRITE_STRING( modelFileName );
    349 
    350     return SYNCHELP_WRITE_N;
     342    return WorldEntity::readState( data, maxLength );
    351343
    352344  }
  • branches/network/src/world_entities/world_entity.cc

    r6277 r6291  
    5959  this->toList(OM_NULL);
    6060
    61   strncpy( modelFileName, "", 1024 );
     61  modelFileName = NULL;
    6262}
    6363
     
    7676
    7777  State::getObjectManager()->toList(this, OM_INIT);
     78
     79  if ( modelFileName )
     80  delete modelFileName;
    7881}
    7982
     
    103106void WorldEntity::loadModel(const char* fileName, float scaling, unsigned int modelNumber)
    104107{
     108  this->modelNumber = modelNumber;
     109  this->modelScaling = scaling;
     110
    105111  if ( fileName != NULL && strcmp(fileName, "") )
    106112  {
    107     strncpy( modelFileName, fileName, 1024 );
     113    if ( modelFileName )
     114    delete modelFileName;
     115    modelFileName = new char[strlen(fileName)+1];
     116    strcpy( modelFileName, fileName );
    108117    // search for the special character # in the LoadParam
    109118    if (strchr(fileName, '#') != NULL)
     
    133142  else
    134143  {
    135     strncpy( modelFileName, "", 1024 );
     144    if ( modelFileName )
     145    delete modelFileName;
     146    modelFileName = new char[1];
     147    strcpy( modelFileName, "" );
    136148    this->setModel(NULL);
    137149  }
     
    332344  glPopMatrix();
    333345}
     346
     347/**
     348 * Writes data from network containing information about the state
     349 * @param data pointer to data
     350 * @param length length of data
     351 * @param sender hostID of sender
     352 */
     353void WorldEntity::writeState( const byte * data, int length, int sender )
     354{
     355  SYNCHELP_READ_BEGIN();
     356  SYNCHELP_READ_STRINGM( modelFileName );
     357  SYNCHELP_READ_FLOAT( modelScaling );
     358  SYNCHELP_READ_INT( modelNumber );
     359  loadModel( modelFileName );
     360}
     361
     362/**
     363 * data copied in data will bee sent to another host
     364 * @param data pointer to data
     365 * @param maxLength max length of data
     366 * @return the number of bytes writen
     367 */
     368int WorldEntity::readState( byte * data, int maxLength )
     369{
     370  SYNCHELP_WRITE_BEGIN();
     371  SYNCHELP_WRITE_STRING( modelFileName );
     372  SYNCHELP_WRITE_FLOAT( modelScaling );
     373  SYNCHELP_WRITE_INT( modelNumber );
     374  return SYNCHELP_WRITE_N;
     375}
  • branches/network/src/world_entities/world_entity.h

    r6277 r6291  
    7272  /** @returns a Reference to the Iterator */
    7373  std::list<WorldEntity*>::iterator& getEntityIterator() { return this->objectListIterator; }
     74
     75  virtual void      writeState(const byte* data, int length, int sender);
     76  virtual int       readState(byte* data, int maxLength );
    7477 protected:
    7578  //  CharacterAttributes*    charAttr;         //!< the character attributes of a world_entity
    76    char                   modelFileName[1024];  //!< the filename of the loaded model
     79
    7780
    7881 private:
     
    8588  OM_LIST                           objectListNumber;   //!< The ObjectList from ObjectManager this Entity is in.
    8689  std::list<WorldEntity*>::iterator objectListIterator; //!< The iterator position of this Entity in the given list of the ObjectManager.
     90  char*                   modelFileName;
     91  int                     modelNumber;
     92  float                   modelScaling;
    8793
    8894
Note: See TracChangeset for help on using the changeset viewer.