Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 6469 in orxonox.OLD for branches/network/src


Ignore:
Timestamp:
Jan 11, 2006, 12:20:56 PM (19 years ago)
Author:
rennerc
Message:

space_ship: tried to implement control synchronization
entities will not be spawned at (0,0,0) anymore

Location:
branches/network/src
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • branches/network/src/lib/coord/p_node.cc

    r6424 r6469  
    10391039  SYNCHELP_READ_FKT( BaseObject::writeState );
    10401040
    1041   PRINTF(0)("name = %s\n", this->getName());
     1041  //PRINTF(0)("name = %s\n", this->getName());
    10421042
    10431043  char * parentName = NULL;
     
    10921092  {
    10931093    SYNCHELP_READ_STRINGM( childName );
    1094     PRINTF(0)("childname = %s\n", childName);
     1094    //PRINTF(0)("childname = %s\n", childName);
    10951095    addChild( childName );
    10961096    delete childName;
     
    11131113  SYNCHELP_WRITE_FKT( BaseObject::readState );
    11141114
    1115   PRINTF(0)("name = %s\n", this->getName());
     1115  //PRINTF(0)("name = %s\n", this->getName());
    11161116
    11171117  if ( this->parent )
     
    11301130  SYNCHELP_WRITE_FLOAT( this->relCoordinate.z );
    11311131
    1132   PRINTF(0)("%s, %f, %f, %f\n", getClassName(), relCoordinate.x, relCoordinate.y, relCoordinate.z);
     1132  //PRINTF(0)("%s, %f, %f, %f\n", getClassName(), relCoordinate.x, relCoordinate.y, relCoordinate.z);
    11331133
    11341134  SYNCHELP_WRITE_FLOAT( this->absCoordinate.x );
     
    11361136  SYNCHELP_WRITE_FLOAT( this->absCoordinate.z );
    11371137
    1138   PRINTF(0)("%s, %f, %f, %f\n", getClassName(), absCoordinate.x, absCoordinate.y, absCoordinate.z);
     1138  //PRINTF(0)("%s, %f, %f, %f\n", getClassName(), absCoordinate.x, absCoordinate.y, absCoordinate.z);
    11391139
    11401140  SYNCHELP_WRITE_FLOAT( this->relDirection.w );
     
    11531153  for (std::list<PNode*>::const_iterator it = children.begin(); it!=children.end(); it++)
    11541154  {
    1155     PRINTF(0)("childname = %s\n", (*it)->getName() );
    11561155    SYNCHELP_WRITE_STRING( (*it)->getName() );
    11571156  }
  • branches/network/src/lib/network/network_game_manager.cc

    r6463 r6469  
    2828#include "game_world.h"
    2929#include "world_entity.h"
     30#include "network_manager.h"
    3031
    3132
     
    8485  {
    8586    b = data[i++];
    86 
    87     PRINTF(0)("WriteBytes: b = %d\n", b);
    8887
    8988    if ( isServer() )
     
    145144    if ( b == REQUEST_ENTITY_LIST )
    146145    {
    147       PRINTF(0)("sending THE list\n");
    148146      sendEntityList( sender );
    149147      continue;
     
    276274      delete b;
    277275    }
     276
    278277  }
    279278  else
     
    404403    if ( !writeToClientBuffer( outBuffer[userID], (int)((*it)->getLeafClassID()) ) )
    405404      return;
    406       //PRINTF(0)("SendEntityList: ClassID = %x\n", (*it)->getRealClassID());
    407405
    408406    if ( !writeToClientBuffer( outBuffer[userID], (int)((*it)->getUniqueID()) ) )
     
    411409    if ( !writeToClientBuffer( outBuffer[userID], (int)((*it)->getOwner()) ) )
    412410      return;
    413 
    414 
    415     PRINTF(0)("id = %x %s %s\n", (int)((*it)->getLeafClassID()), (*it)->getClassName(), (*it)->getName());
    416 
    417 
    418     /*if ( (*it)->isA(CL_WORLD_ENTITY) )
    419     {
    420       n = dynamic_cast<WorldEntity*>((*it))->readState( outBuffer[userID].buffer, outBuffer[userID].maxLength-outBuffer[userID].length );
    421       if ( n = 0 )
    422       {
    423         PRINTF(2)("n = 0\n");
    424       }
    425       outBuffer[userID].length += n;
    426   }*/
    427411
    428412    it++;
     
    478462    PRINTF(0)("Fabricated %s with id %d\n", s->getClassName(), s->getUniqueID());
    479463
     464    //NOTE: hack to prevent collision
     465    if ( b->isA(CL_WORLD_ENTITY) )
     466    {
     467      if ( NetworkManager::getInstance()->getHostID()!=0 )
     468      {
     469        static Vector pos = Vector(1000.0, 1000.0, 1000.0);
     470        PNode *p = dynamic_cast<PNode*>(b);
     471        p->setRelCoor(pos);
     472        p->updateNode(0);
     473        pos += Vector(1000.0, 1000.0, 1000.0);
     474      }
     475    }
     476
    480477    return b;
    481478  }
     
    720717    i += Converter::byteArrayToInt( &data[i], &owner );
    721718
    722     PRINTF(0)("before fabricate\n");
    723719    if ( classID != CL_NETWORK_GAME_MANAGER && classID != CL_HANDSHAKE )
    724720    {
  • branches/network/src/lib/network/network_stream.cc

    r6341 r6469  
    291291        dataLength -= sizeof(header);
    292292
    293         PRINTF(0)("read %d bytes from socket uniqueID = %d\n", dataLength, header.synchronizeableID);
     293        PRINTF(5)("read %d bytes from socket uniqueID = %d\n", dataLength, header.synchronizeableID);
    294294
    295295        if ( dataLength != header.length )
  • branches/network/src/world_entities/power_ups/param_power_up.cc

    r6424 r6469  
    138138    SYNCHELP_READ_INT( this->min_value );
    139139    SYNCHELP_READ_INT( this->max_value );
     140    respawn();
    140141  }
    141142
     
    162163    SYNCHELP_WRITE_FKT( PowerUp::readState );
    163164
    164     int i = this->type;
     165    int i = (int)this->type;
    165166    SYNCHELP_WRITE_INT( i );
    166167    SYNCHELP_WRITE_INT( this->value );
  • branches/network/src/world_entities/skybox.cc

    r6341 r6469  
    230230  SYNCHELP_READ_STRINGM( textureName );
    231231
    232   PRINT(0)("GOT DATA: size=%f texture='%s'\n", size, textureName);
    233 
    234232  this->setSize( size );
    235233  this->setTextureAndType( textureName, "jpg" );
  • branches/network/src/world_entities/space_ships/space_ship.cc

    r6463 r6469  
    525525}
    526526
     527#define MASK_bUp         1
     528#define MASK_bDown       2
     529#define MASK_bLeft       4
     530#define MASK_bRight      8
     531#define MASK_bAscend    16
     532#define MASK_bDescend   32
     533#define MASK_bFire      64
     534#define MASK_bRollL    128
     535#define MASK_bRollR    256
     536
     537#define DATA_state       1
     538#define DATA_flags       2
     539#define DATA_mouse       3
    527540
    528541int SpaceShip::writeBytes( const byte * data, int length, int sender )
    529542{
    530   setRequestedSync( false );
    531   setIsOutOfSync( false );
    532 
    533543  SYNCHELP_READ_BEGIN();
    534544
    535   SYNCHELP_READ_FKT( WorldEntity::writeState );
     545  byte b;
     546  SYNCHELP_READ_BYTE( b );
     547
     548  if ( b == DATA_state && this->getHostID()!=this->getOwner() )
     549  {
     550    setRequestedSync( false );
     551    setIsOutOfSync( false );
     552    SYNCHELP_READ_FKT( WorldEntity::writeState );
     553    SYNCHELP_READ_FLOAT( cycle );
     554  }
     555
     556  if ( b == DATA_flags && this->getHostID()!=this->getOwner() )
     557  {
     558    int flags;
     559    SYNCHELP_READ_INT( flags );
     560
     561    bUp = flags & MASK_bUp != 0;
     562    bDown = flags & MASK_bDown != 0;
     563    bLeft = flags & MASK_bLeft != 0;
     564    bRight = flags & MASK_bRight != 0;
     565    bAscend = flags & MASK_bAscend != 0;
     566    bDescend = flags & MASK_bDescend != 0;
     567    bFire = flags & MASK_bFire != 0;
     568    bRollL = flags & MASK_bRollL != 0;
     569    bRollR = flags & MASK_bRollR != 0;
     570  }
     571
     572  if ( b == DATA_mouse && this->getHostID()!=this->getOwner() )
     573  {
     574    SYNCHELP_READ_FLOAT( xMouse );
     575    SYNCHELP_READ_FLOAT( yMouse );
     576    SYNCHELP_READ_FLOAT( mouseSensitivity ); //TODO: remove this two lines
     577    SYNCHELP_READ_FLOAT( cycle );
     578  }
    536579
    537580  return SYNCHELP_READ_N;
    538581}
    539582
     583
     584
    540585int SpaceShip::readBytes( byte * data, int maxLength, int * reciever )
    541586{
     587  SYNCHELP_WRITE_BEGIN();
     588
    542589  if ( isOutOfSync() && !requestedSync() && this->getHostID()!=this->getOwner() )
    543590  {
     
    551598    *reciever = rec;
    552599
    553     SYNCHELP_WRITE_BEGIN();
     600    SYNCHELP_WRITE_BYTE( (byte)DATA_state );
    554601
    555602    SYNCHELP_WRITE_FKT( WorldEntity::readState );
     603    SYNCHELP_WRITE_FLOAT( cycle );
    556604
    557605    return SYNCHELP_WRITE_N;
    558606  }
    559607
     608
    560609  *reciever = 0;
    561   return 0;
    562 }
     610
     611  if ( this->getHostID()!=this->getOwner() )
     612  {
     613    int mask = 0;
     614
     615    if ( bUp )
     616      mask |= MASK_bUp;
     617    if ( bDown )
     618      mask |= MASK_bDown;
     619    if ( bLeft )
     620      mask |= MASK_bLeft;
     621    if ( bRight )
     622      mask |= MASK_bRight;
     623    if ( bAscend )
     624      mask |= MASK_bAscend;
     625    if ( bFire )
     626      mask |= MASK_bFire;
     627    if ( bRollL )
     628      mask |= MASK_bRollL;
     629    if ( bRollR )
     630      mask |= MASK_bRollR;
     631
     632    static int oldMask = mask+1; //so it it different the first time!
     633    static float oldxMouse = xMouse + 1.0;
     634    static float oldyMouse = yMouse + 1.0;
     635
     636    if ( mask != oldMask )
     637    {
     638      oldMask = mask;
     639      SYNCHELP_WRITE_BYTE( DATA_flags );
     640      SYNCHELP_WRITE_INT( mask );
     641    }
     642
     643    if ( oldxMouse != xMouse || oldyMouse != yMouse )
     644    {
     645      oldxMouse = xMouse;
     646      oldyMouse = yMouse;
     647      SYNCHELP_WRITE_BYTE( DATA_mouse );
     648      SYNCHELP_WRITE_FLOAT( xMouse );
     649      SYNCHELP_WRITE_FLOAT( yMouse );
     650      SYNCHELP_WRITE_FLOAT( mouseSensitivity );
     651      SYNCHELP_WRITE_FLOAT( cycle );  //TODO: remove this two lines
     652    }
     653  }
     654
     655  return SYNCHELP_WRITE_N;
     656}
  • branches/network/src/world_entities/world_entity.cc

    r6424 r6469  
    402402
    403403  SYNCHELP_READ_STRINGM( modelFileName );
     404
    404405  if ( strcmp(modelFileName, "") )
    405     this->md2TextureFileName = modelFileName;
     406    if ( strstr(modelFileName, ResourceManager::getInstance()->getDataDir()) )
     407    {
     408      this->md2TextureFileName = new char[strlen(modelFileName)-strlen(ResourceManager::getInstance()->getDataDir())+1];
     409      strcpy((char*)this->md2TextureFileName, modelFileName+strlen(ResourceManager::getInstance()->getDataDir()));
     410    }
     411    else
     412    {
     413      this->md2TextureFileName = modelFileName;
     414    }
    406415
    407416  return SYNCHELP_READ_N;
Note: See TracChangeset for help on using the changeset viewer.