Changeset 6291 in orxonox.OLD for branches/network/src/world_entities/world_entity.cc
- Timestamp:
- Dec 26, 2005, 1:16:13 AM (20 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/network/src/world_entities/world_entity.cc
r6277 r6291 59 59 this->toList(OM_NULL); 60 60 61 strncpy( modelFileName, "", 1024 );61 modelFileName = NULL; 62 62 } 63 63 … … 76 76 77 77 State::getObjectManager()->toList(this, OM_INIT); 78 79 if ( modelFileName ) 80 delete modelFileName; 78 81 } 79 82 … … 103 106 void WorldEntity::loadModel(const char* fileName, float scaling, unsigned int modelNumber) 104 107 { 108 this->modelNumber = modelNumber; 109 this->modelScaling = scaling; 110 105 111 if ( fileName != NULL && strcmp(fileName, "") ) 106 112 { 107 strncpy( modelFileName, fileName, 1024 ); 113 if ( modelFileName ) 114 delete modelFileName; 115 modelFileName = new char[strlen(fileName)+1]; 116 strcpy( modelFileName, fileName ); 108 117 // search for the special character # in the LoadParam 109 118 if (strchr(fileName, '#') != NULL) … … 133 142 else 134 143 { 135 strncpy( modelFileName, "", 1024 ); 144 if ( modelFileName ) 145 delete modelFileName; 146 modelFileName = new char[1]; 147 strcpy( modelFileName, "" ); 136 148 this->setModel(NULL); 137 149 } … … 332 344 glPopMatrix(); 333 345 } 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 */ 353 void 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 */ 368 int 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 }
Note: See TracChangeset
for help on using the changeset viewer.