Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

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


Ignore:
Timestamp:
Nov 30, 2005, 11:09:18 AM (19 years ago)
Author:
patrick
Message:

network: server/client orxonox now works

Location:
branches/network/src
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • branches/network/src/defs/debug.h

    r5822 r5833  
    107107#endif
    108108#ifndef NO_SHELL
    109 #define PRINT_EXEC       ShellBuffer::addBufferLineStatic
     109#define PRINT_EXEC       printf //ShellBuffer::addBufferLineStatic
    110110#else /* NO_SHELL */
    111111#define PRINT_EXEC       printf
  • branches/network/src/lib/network/network_stream.cc

    r5829 r5833  
    4444  this->init();
    4545  /* initialize the references */
     46  this->type = NET_CLIENT;
    4647  this->networkSocket = new NetworkSocket();
    4748  this->networkProtocol = new NetworkProtocol();
     
    5253NetworkStream::NetworkStream(IPaddress& address, NodeType type)
    5354{
     55  this->type = type;
    5456  this->init();
    5557  this->networkSocket = new NetworkSocket(address);
     
    6264NetworkStream::NetworkStream(unsigned int port, NodeType type)
    6365{
     66  this->type = type;
    6467  this->init();
    6568  this->networkSocket = new NetworkSocket();
     
    7477    : DataStream()
    7578{
     79  this->type = type;
    7680  this->init();
    7781  this->networkSocket = new NetworkSocket(address);
     
    8690    : DataStream()
    8791{
     92  this->type = type;
    8893  this->init();
    8994  this->networkSocket = new NetworkSocket();
     
    134139  PRINT(0)("============= DOWNSTREAM:===============\n");
    135140  /* first of all read the synchronizeable's data: */
    136   //if(this->isServer())
    137   dataLength = this->synchronizeables->readBytes((byte*)downBuffer);
     141  if( this->isServer())
     142    dataLength = this->synchronizeables->readBytes((byte*)downBuffer);
    138143
    139144  if( dataLength > 0)
     
    181186    if( dataLength == this->packetHeader.length)
    182187    {
    183       printf("NetworkStream::processData() - Got Data: \n");
     188      printf("NetworkStream::processData() - Got Data: %i bytes\n", dataLength);
    184189      /* send the received data to connectionMonitor */
    185190      this->connectionMonitor->processPacket((byte*)upBuffer, this->packetHeader.length);
    186191      /* now pass the data to the sync object */
    187       //if(!this->isServer())
    188       this->synchronizeables->writeBytes((byte*)upBuffer, this->packetHeader.length);
     192      if( !this->isServer())
     193        this->synchronizeables->writeBytes((byte*)upBuffer, this->packetHeader.length);
    189194
    190195      this->state = NET_REC_HEADER;
  • branches/network/src/world_entities/player.cc

    r5829 r5833  
    445445void Player::writeBytes(const byte* data, int length)
    446446{
    447   PRINTF(0)("Player: got %i bytes of data\n", length);
     447 // PRINTF(0)("Player: got %i bytes of data\n", length);
    448448  this->inLength = length;
    449449
     
    476476  for( int i = 0; i < length; i++)
    477477  {
     478   
    478479    code = data[i];
    479480
     481    //PRINTF(0)("got byte: %u\n", data[i]);
    480482    /* is it a time code? */
    481483    if( code == TIME)
    482484    {
    483485      /* is it the first time */
    484       if( time > 0.0f )
    485       {
    486         /* apply movement */
    487         Vector move = accel * time;
    488 
    489         if (accel.z < 0)
    490           this->setRelDirSoft(Quaternion(-.4, Vector(1,0,0)), 5);
    491         else if (accel.z > 0)
    492           this->setRelDirSoft(Quaternion(.4, Vector(1,0,0)), 5);
    493         else
    494           this->setRelDirSoft(Quaternion(0, Vector(1,0,0)), 5);
    495         this->shiftCoor (move);
    496       }
     486     
    497487      /* read out new movement */
    498488      time = (float)(data[++i] / 100.0f);
    499       PRINTF(0)("Got time: %f msec\n", time);
     489      //PRINTF(0)("Got time: %f msec\n", time);
    500490    }
     491   
    501492    else if( code == UP && this->getRelCoor().x < 20)
    502493      accel = accel+(direction*acceleration);
     
    507498    else if( code == RIGHT && TrackManager::getInstance()->getWidth() > this->getRelCoor().z*2)
    508499      accel = accel + (orthDirection*acceleration);
    509   }
    510 
     500 
     501    if( time > 0.0f )
     502    {
     503      /* apply movement */
     504      Vector move = accel * time;
     505
     506      if (accel.z < 0)
     507        this->setRelDirSoft(Quaternion(-.4, Vector(1,0,0)), 5);
     508      else if (accel.z > 0)
     509        this->setRelDirSoft(Quaternion(.4, Vector(1,0,0)), 5);
     510      else
     511        this->setRelDirSoft(Quaternion(0, Vector(1,0,0)), 5);
     512      this->shiftCoor (move);
     513    }
     514
     515  }
     516
     517 
    511518
    512519
     
    522529int Player::readBytes(byte* data)
    523530{
    524   PRINTF(0)("Player: sent %i bytes of data\n", this->sentLength);
     531 // PRINTF(0)("Player: sent %i bytes of data\n", this->sentLength);
    525532
    526533  /* copy data */
Note: See TracChangeset for help on using the changeset viewer.