Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 6256 in orxonox.OLD


Ignore:
Timestamp:
Dec 21, 2005, 7:26:49 PM (18 years ago)
Author:
rennerc
Message:

network_socket: can now send more than 255 bytes
network_game_manager: fixed some bugs

Location:
branches/network/src/lib/network
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • branches/network/src/lib/network/network_game_manager.cc

    r6250 r6256  
    7373  byte b;
    7474
    75   while ( i<length )
     75  while ( i<length-1 )
    7676  {
    7777    b = data[i++];
     78
     79    PRINTF(0)("WriteBytes: b = %d\n", b);
    7880
    7981    if ( isServer() )
     
    9294      }
    9395    }
    94 
    95     if ( !isServer() )
     96    else
    9697    {
    9798      if ( b == CREATE_ENTITY )
     
    362363    return;
    363364
     365  PRINTF(0)("SendEntityList: n = %d\n", networkStream->getSyncCount());
     366
    364367  while ( it != e )
    365368  {
    366369    if ( !writeToClientBuffer( outBuffer[userID], (*it)->getClassID() ) )
    367370      return;
     371
     372    PRINTF(0)("SendEntityList: ClassID = %x\n", (*it)->getClassID());
    368373
    369374    if ( !writeToClientBuffer( outBuffer[userID], (*it)->getUniqueID() ) )
     
    409414  if ( !b )
    410415  {
    411     PRINTF(1)("Could not fabricate Object with classID %d\n", classID);
    412     return;
     416    PRINTF(1)("Could not fabricate Object with classID %x\n", classID);
     417    return;
     418  }
     419  else
     420  {
     421    PRINTF(0)("Fabricated entity: %s\n", b->getClassName());
    413422  }
    414423
     
    422431  else
    423432  {
    424     PRINTF(1)("Class with ID %d is not a synchronizeable!", (int)classID);
     433    PRINTF(1)("Class with ID %x is not a synchronizeable!", (int)classID);
    425434    delete b;
    426435  }
     
    549558  }
    550559  int classID;
    551   i += Converter::byteArrayToInt( data, &classID );
     560  i += Converter::byteArrayToInt( &data[i], &classID );
    552561
    553562  createEntity( (ClassID)classID );
     
    564573  }
    565574  int uniqueID;
    566   i += Converter::byteArrayToInt( data, &uniqueID );
     575  i += Converter::byteArrayToInt( &data[i], &uniqueID );
    567576
    568577  removeEntity( uniqueID );
     
    579588  }
    580589  int classID;
    581   i += Converter::byteArrayToInt( data, &classID );
     590  i += Converter::byteArrayToInt( &data[i], &classID );
    582591
    583592  if ( INTSIZE > length-i )
     
    587596  }
    588597  int uniqueID;
    589   i += Converter::byteArrayToInt( data, &uniqueID );
     598  i += Converter::byteArrayToInt( &data[i], &uniqueID );
    590599
    591600  if ( INTSIZE > length-i )
     
    595604  }
    596605  int owner;
    597   i += Converter::byteArrayToInt( data, &owner );
     606  i += Converter::byteArrayToInt( &data[i], &owner );
    598607
    599608  doCreateEntity( (ClassID)classID, uniqueID, owner );
     
    610619  }
    611620  int uniqueID;
    612   i += Converter::byteArrayToInt( data, &uniqueID );
     621  i += Converter::byteArrayToInt( &data[i], &uniqueID );
    613622
    614623  doRemoveEntity( uniqueID );
     
    624633    return false;
    625634  }
     635
     636  PRINTF(0)("HandleCreateEntityList:  data[i..i+3] = %d %d %d %d\n", data[i], data[i+1], data[i+2], data[i+3]);
     637
    626638  int n;
    627   i += Converter::byteArrayToInt( data, &n );
     639  i += Converter::byteArrayToInt( &data[i], &n );
     640
     641
     642  PRINTF(0)("HandleCreateEntityList: n = %d\n", n);
    628643
    629644  int classID, uniqueID, owner;
     
    637652      return false;
    638653    }
    639     i += Converter::byteArrayToInt( data, &classID );
     654    i += Converter::byteArrayToInt( &data[i], &classID );
    640655
    641656    if ( INTSIZE > length-i )
     
    644659      return false;
    645660    }
    646     i += Converter::byteArrayToInt( data, &uniqueID );
     661    i += Converter::byteArrayToInt( &data[i], &uniqueID );
    647662
    648663    if ( INTSIZE > length-i )
     
    651666      return false;
    652667    }
    653     i += Converter::byteArrayToInt( data, &owner );
     668    i += Converter::byteArrayToInt( &data[i], &owner );
    654669
    655670    doCreateEntity( (ClassID)classID, uniqueID, owner );
     
    667682  }
    668683  int n;
    669   i += Converter::byteArrayToInt( data, &n );
     684  i += Converter::byteArrayToInt( &data[i], &n );
    670685
    671686  int uniqueID;
     
    679694      return false;
    680695    }
    681     i += Converter::byteArrayToInt( data, &uniqueID );
     696    i += Converter::byteArrayToInt( &data[i], &uniqueID );
    682697
    683698    doRemoveEntity( uniqueID );
     
    696711
    697712  int uniqueID;
    698   i += Converter::byteArrayToInt( data, &uniqueID );
     713  i += Converter::byteArrayToInt( &data[i], &uniqueID );
    699714
    700715  doYouAre( uniqueID );
     
    711726  }
    712727  int uniqueID;
    713   i += Converter::byteArrayToInt( data, &uniqueID );
     728  i += Converter::byteArrayToInt( &data[i], &uniqueID );
    714729
    715730  doRequestSync( uniqueID, sender );
     
    733748bool NetworkGameManager::writeToClientBuffer( clientBuffer & cb, int i )
    734749{
    735   int n = Converter::intToByteArray( i, cb.buffer, cb.maxLength-cb.length );
     750  int n = Converter::intToByteArray( i, cb.buffer+cb.length, cb.maxLength-cb.length );
    736751  cb.length += n;
    737752
  • branches/network/src/lib/network/network_socket.cc

    r6139 r6256  
    2121#define DEBUG_MODULE_NETWORK
    2222
     23#include "converter.h"
    2324
    2425/* include your own header */
     
    398399{
    399400  PRINTF(5)("NetworkSocket::writePacket()\n");
    400   if (length>255)
    401   {
    402     PRINTF(1)("Packet length > 255!\n");
    403     return false;
    404   }
    405 
    406   byte blen = length;
    407 
    408   writeBytes(&blen, 1);
     401
     402  byte blen[INTSIZE];
     403
     404  Converter::intToByteArray( length, blen, INTSIZE );
     405
     406  writeBytes(blen, INTSIZE);
    409407  writeBytes(data, length);
    410408}
     
    413411{
    414412  PRINTF(5)("NetworkSocket::readPacket()\n");
    415   if (incomingBufferLength<1)
    416   {
    417     return 0;
    418   }
    419 
    420   byte blen = incomingBuffer[0];
     413  if (incomingBufferLength<INTSIZE)
     414  {
     415    return 0;
     416  }
     417
     418  int blen;
     419  Converter::byteArrayToInt( incomingBuffer, &blen );
    421420
    422421  if (blen>maxLength)
     
    431430  }
    432431
    433   readBytes(&blen, 1);
     432  byte t[INTSIZE];
     433  readBytes(t, INTSIZE);
    434434  int res = readBytes(data, blen);
    435435
  • branches/network/src/lib/network/network_stream.cc

    r6230 r6256  
    262262      } while( reciever!=0 );
    263263    }
    264     else
    265     {
    266       PRINTF(0)("synchronizeables == NULL");
    267     }
    268264  }
    269265
Note: See TracChangeset for help on using the changeset viewer.