Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

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

commit code which crashes my system so bensch can test it

File:
1 edited

Legend:

Unmodified
Added
Removed
  • 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}
Note: See TracChangeset for help on using the changeset viewer.