Changeset 6291 in orxonox.OLD for branches/network/src/world_entities
- Timestamp:
- Dec 26, 2005, 1:16:13 AM (19 years ago)
- Location:
- branches/network/src/world_entities
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/network/src/world_entities/terrain.cc
r6277 r6291 324 324 setIsOutOfSync( false ); 325 325 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); 332 327 } 333 328 … … 345 340 *reciever = rec; 346 341 347 SYNCHELP_WRITE_BEGIN(); 348 SYNCHELP_WRITE_STRING( modelFileName ); 349 350 return SYNCHELP_WRITE_N; 342 return WorldEntity::readState( data, maxLength ); 351 343 352 344 } -
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 } -
branches/network/src/world_entities/world_entity.h
r6277 r6291 72 72 /** @returns a Reference to the Iterator */ 73 73 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 ); 74 77 protected: 75 78 // CharacterAttributes* charAttr; //!< the character attributes of a world_entity 76 char modelFileName[1024]; //!< the filename of the loaded model 79 77 80 78 81 private: … … 85 88 OM_LIST objectListNumber; //!< The ObjectList from ObjectManager this Entity is in. 86 89 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; 87 93 88 94
Note: See TracChangeset
for help on using the changeset viewer.