Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 6784 in orxonox.OLD for branches/network/src/lib


Ignore:
Timestamp:
Jan 26, 2006, 8:03:40 PM (19 years ago)
Author:
rennerc
Message:

sync: added debug feature

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

Legend:

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

    r6695 r6784  
    10771077  SYNCHELP_READ_BEGIN();
    10781078
    1079   SYNCHELP_READ_FKT( BaseObject::writeState );
     1079  SYNCHELP_READ_FKT( BaseObject::writeState, NWT_PN_BO_WRITESTATE );
    10801080
    10811081//   char * parentName = NULL;
     
    10941094
    10951095  int parentMode;
    1096   SYNCHELP_READ_INT( parentMode );
     1096  SYNCHELP_READ_INT( parentMode, NWT_PN_PARENTMODE );
    10971097  this->setParentMode((PARENT_MODE)parentMode);
    10981098
    10991099  float f1, f2, f3, f4;
    11001100
    1101   SYNCHELP_READ_FLOAT( f1 );
    1102   SYNCHELP_READ_FLOAT( f2 );
    1103   SYNCHELP_READ_FLOAT( f3 );
     1101  SYNCHELP_READ_FLOAT( f1, NWT_PN_COORX );
     1102  SYNCHELP_READ_FLOAT( f2, NWT_PN_COORY );
     1103  SYNCHELP_READ_FLOAT( f3, NWT_PN_COORZ );
    11041104  this->setRelCoor( f1, f2, f3 );
    11051105
    11061106
    1107   SYNCHELP_READ_FLOAT( f1 );
    1108   SYNCHELP_READ_FLOAT( f2 );
    1109   SYNCHELP_READ_FLOAT( f3 );
    1110   SYNCHELP_READ_FLOAT( f4 );
     1107  SYNCHELP_READ_FLOAT( f1, NWT_PN_ROTV );
     1108  SYNCHELP_READ_FLOAT( f2, NWT_PN_ROTX );
     1109  SYNCHELP_READ_FLOAT( f3, NWT_PN_ROTY );
     1110  SYNCHELP_READ_FLOAT( f4, NWT_PN_ROTZ );
    11111111  this->setRelDir( Quaternion( Vector(f2, f3, f4), f1 ) );
    11121112
     
    11401140  SYNCHELP_WRITE_BEGIN();
    11411141
    1142   SYNCHELP_WRITE_FKT( BaseObject::readState );
     1142  SYNCHELP_WRITE_FKT( BaseObject::readState, NWT_PN_BO_WRITESTATE );
    11431143
    11441144//   if ( this->parent )
     
    11511151//   }
    11521152
    1153   SYNCHELP_WRITE_INT( this->parentMode );
    1154 
    1155   SYNCHELP_WRITE_FLOAT( this->relCoordinate.x );
    1156   SYNCHELP_WRITE_FLOAT( this->relCoordinate.y );
    1157   SYNCHELP_WRITE_FLOAT( this->relCoordinate.z );
    1158 
    1159   SYNCHELP_WRITE_FLOAT( this->relDirection.w );
    1160   SYNCHELP_WRITE_FLOAT( this->relDirection.v.x );
    1161   SYNCHELP_WRITE_FLOAT( this->relDirection.v.y );
    1162   SYNCHELP_WRITE_FLOAT( this->relDirection.v.z );
     1153  SYNCHELP_WRITE_INT( this->parentMode, NWT_PN_PARENTMODE );
     1154
     1155  SYNCHELP_WRITE_FLOAT( this->relCoordinate.x, NWT_PN_COORX );
     1156  SYNCHELP_WRITE_FLOAT( this->relCoordinate.y, NWT_PN_COORY );
     1157  SYNCHELP_WRITE_FLOAT( this->relCoordinate.z, NWT_PN_COORZ );
     1158
     1159  SYNCHELP_WRITE_FLOAT( this->relDirection.w, NWT_PN_ROTV );
     1160  SYNCHELP_WRITE_FLOAT( this->relDirection.v.x, NWT_PN_ROTX );
     1161  SYNCHELP_WRITE_FLOAT( this->relDirection.v.y, NWT_PN_ROTY );
     1162  SYNCHELP_WRITE_FLOAT( this->relDirection.v.z, NWT_PN_ROTZ );
    11631163
    11641164//   int n = children.size();
     
    12091209
    12101210  byte flags = 0;
    1211   SYNCHELP_READ_BYTE( flags );
     1211  SYNCHELP_READ_BYTE( flags, NWT_PN_FLAGS );
    12121212  //PRINTF(0)("%s::FLAGS = %d\n", this->getName(), flags);
    12131213
     
    12161216  if ( flags & __FLAG_COOR )
    12171217  {
    1218     SYNCHELP_READ_FLOAT( f1 );
    1219     SYNCHELP_READ_FLOAT( f2 );
    1220     SYNCHELP_READ_FLOAT( f3 );
     1218    SYNCHELP_READ_FLOAT( f1, NWT_PN_SCOORX );
     1219    SYNCHELP_READ_FLOAT( f2, NWT_PN_SCOORY );
     1220    SYNCHELP_READ_FLOAT( f3, NWT_PN_SCOORZ );
    12211221    PRINTF(0)("RCVD COOR: %f %f %f\n", f1, f2, f3);
    12221222    this->setRelCoor( f1, f2, f3 );
     
    12251225  if ( flags & __FLAG_ROT )
    12261226  {
    1227     SYNCHELP_READ_FLOAT( f1 );
    1228     SYNCHELP_READ_FLOAT( f2 );
    1229     SYNCHELP_READ_FLOAT( f3 );
    1230     SYNCHELP_READ_FLOAT( f4 );
     1227    SYNCHELP_READ_FLOAT( f1, NWT_PN_SROTV );
     1228    SYNCHELP_READ_FLOAT( f2, NWT_PN_SROTX );
     1229    SYNCHELP_READ_FLOAT( f3, NWT_PN_SROTY );
     1230    SYNCHELP_READ_FLOAT( f4, NWT_PN_SROTZ );
    12311231    PRINTF(0)("RCVD QUAT: %f %f %f %f\n", f1, f2, f3, f4);
    12321232    //this->setRelDir( Quaternion( Vector(f2, f3, f4), f1 ) );
     
    12701270
    12711271
    1272   SYNCHELP_WRITE_BYTE( flags );
     1272  SYNCHELP_WRITE_BYTE( flags, NWT_PN_FLAGS );
    12731273  //PRINTF(0)("FLAGS = %d\n", flags);
    12741274
     
    12781278    PRINTF(0)("SEND COOR: %f %f %f\n", this->relCoordinate.x, this->relCoordinate.y, this->relCoordinate.z);
    12791279
    1280     SYNCHELP_WRITE_FLOAT( this->relCoordinate.x );
    1281     SYNCHELP_WRITE_FLOAT( this->relCoordinate.y );
    1282     SYNCHELP_WRITE_FLOAT( this->relCoordinate.z );
     1280    SYNCHELP_WRITE_FLOAT( this->relCoordinate.x, NWT_PN_SCOORX );
     1281    SYNCHELP_WRITE_FLOAT( this->relCoordinate.y, NWT_PN_SCOORY );
     1282    SYNCHELP_WRITE_FLOAT( this->relCoordinate.z, NWT_PN_SCOORZ );
    12831283
    12841284    coorx = relCoordinate.x;
     
    12921292    PRINTF(0)("SEND QUAT: %f %f %f %f\n", this->absDirection.w, this->absDirection.v.x, this->absDirection.v.y, this->absDirection.v.z);
    12931293
    1294     SYNCHELP_WRITE_FLOAT( this->absDirection.w );
    1295     SYNCHELP_WRITE_FLOAT( this->absDirection.v.x );
    1296     SYNCHELP_WRITE_FLOAT( this->absDirection.v.y );
    1297     SYNCHELP_WRITE_FLOAT( this->absDirection.v.z );
     1294    SYNCHELP_WRITE_FLOAT( this->absDirection.w, NWT_PN_SROTV );
     1295    SYNCHELP_WRITE_FLOAT( this->absDirection.v.x, NWT_PN_SROTX );
     1296    SYNCHELP_WRITE_FLOAT( this->absDirection.v.y, NWT_PN_SROTY );
     1297    SYNCHELP_WRITE_FLOAT( this->absDirection.v.z, NWT_PN_SROTZ );
    12981298
    12991299    rotw = absDirection.w;
  • branches/network/src/lib/lang/base_object.cc

    r6640 r6784  
    204204    objectName = NULL;
    205205  }
    206   SYNCHELP_READ_STRINGM( this->objectName );
     206  SYNCHELP_READ_STRINGM( this->objectName, NWT_BO_NAME );
    207207  if ( this->objectName && !strcmp(this->objectName, "") )
    208208  {
     
    225225
    226226  //PRINTF(0)("objectname = %s\n", this->objectName);
    227   SYNCHELP_WRITE_STRING( this->objectName );
     227  SYNCHELP_WRITE_STRING( this->objectName, NWT_BO_NAME );
    228228
    229229  return SYNCHELP_WRITE_N;
  • branches/network/src/lib/network/handshake.cc

    r6753 r6784  
    9595  if ( !isServer() && hasState( HS_RECVD_VER ) && !hasState( HS_RECVD_HID ) )
    9696  {
    97     if ( length != INTSIZE+INTSIZE )
    98     {
    99       PRINTF(0)("hostID packet has wrong size %d instead of %d\n", length, 1);
    100       setState( HS_COMPLETED );
    101       return 0;
    102     }
     97    /*if ( length != INTSIZE+INTSIZE )
     98    {
     99      PRINTF(0)("hostID packet has wrong size %d instead of %d\n", length, INTSIZE+INTSIZE);
     100      setState( HS_COMPLETED );
     101      return 0;
     102  }*/
    103103
    104104    setState( HS_COMPLETED );
    105105    setState( HS_RECVD_HID );
    106106    this->isOk = true;
    107     SYNCHELP_READ_INT( this->newHostId );
    108     SYNCHELP_READ_INT( this->newNetworkGameManagerId );
     107    SYNCHELP_READ_INT( this->newHostId, NWT_HS_HOST_ID );
     108    SYNCHELP_READ_INT( this->newNetworkGameManagerId, NWT_HS_NGM_ID );
    109109
    110110    if ( newHostId == 0 )
     
    180180      isOk = false;
    181181      //memcpy(data, (byte*)0, 4);
    182       SYNCHELP_WRITE_INT( 0 );
    183       SYNCHELP_WRITE_INT( 0 );
     182      SYNCHELP_WRITE_INT( 0, NWT_HS_HOST_ID);
     183      SYNCHELP_WRITE_INT( 0, NWT_HS_NGM_ID);
    184184    }
    185185    else
     
    187187      isOk = true;
    188188      //memcpy(data, &clientId, 4);
    189       SYNCHELP_WRITE_INT( clientId );
    190       SYNCHELP_WRITE_INT( networkGameManagerId );
     189      SYNCHELP_WRITE_INT( clientId, NWT_HS_HOST_ID );
     190      SYNCHELP_WRITE_INT( networkGameManagerId, NWT_HS_NGM_ID );
    191191    }
    192192    *reciever = clientId;
  • branches/network/src/lib/network/network_game_manager.cc

    r6737 r6784  
    167167  if ( !isServer() && !hasRequestedWorld )
    168168  {
    169     SYNCHELP_WRITE_BEGIN();
    170     byte b = NET_REQUEST_ENTITY_LIST;
    171     SYNCHELP_WRITE_BYTE( b );
     169    assert( maxLength >= 1 );
     170    data[0] = NET_REQUEST_ENTITY_LIST;
    172171    hasRequestedWorld = true;
    173     return SYNCHELP_WRITE_N;
     172    return 1;
    174173  }
    175174
  • branches/network/src/lib/network/synchronizeable.h

    r6753 r6784  
    2020#define STATE_OUTOFSYNC 2
    2121#define STATE_REQUESTEDSYNC 4
     22
     23enum {
     24  NWT_SS_WE_STATE = 1000000,
     25  NWT_SS_B,
     26  NWT_SS_FLAGS,
     27  NWT_SS_MOUSEDIRX,
     28  NWT_SS_MOUSEDIRY,
     29  NWT_SS_MOUSEDIRZ,
     30  NWT_SS_MOUSEDIRW,
     31  NWT_SS_PN_SYNC,
     32 
     33  NWT_HS_HOST_ID,
     34  NWT_HS_NGM_ID,
     35 
     36  NWT_PN_BO_WRITESTATE,
     37  NWT_PN_PARENTMODE,
     38  NWT_PN_COORX,
     39  NWT_PN_COORY,
     40  NWT_PN_COORZ,
     41  NWT_PN_ROTX,
     42  NWT_PN_ROTY,
     43  NWT_PN_ROTZ,
     44  NWT_PN_ROTV,
     45 
     46  NWT_PN_FLAGS,
     47  NWT_PN_SCOORX,
     48  NWT_PN_SCOORY,
     49  NWT_PN_SCOORZ,
     50  NWT_PN_SROTX,
     51  NWT_PN_SROTY,
     52  NWT_PN_SROTZ,
     53  NWT_PN_SROTV,
     54 
     55  NWT_BO_NAME,
     56 
     57  NWT_WE_PN_WRITESTATE,
     58  NWT_WE_PN_MODELFILENAME,
     59  NWT_WE_PN_SCALING,
     60 
     61  NWT_GT_WE_STATE,
     62 
     63  NWT_SB_WE_STATE,
     64  NWT_SB_SIZE,
     65  NWT_SB_TEXTURENAME,
     66 
     67  NWT_TER_WE_STATE,
     68 
     69  NWT_PU_WE_STATE,
     70 
     71  NWT_TPU_WE_STATE,
     72 
     73  NWT_LPU_WE_STATE,
     74 
     75  NWT_WPU_WE_STATE,
     76 
     77  NWT_PPU_WE_STATE,
     78  NWT_PPU_TYPE,
     79  NWT_PPU_VALUE,
     80  NWT_PPU_MINVALUE,
     81  NWT_PPU_MAXVALUE,
     82
     83  NWT_WAT_STATE,
     84  NWT_WAT_WE_STATE,
     85  NWT_WAT_SIZEX,
     86  NWT_WAT_SIZEY,
     87  NWT_WAT_RESX,
     88  NWT_WAT_RESY,
     89  NWT_WAT_HEIGHT
     90};
    2291
    2392
     
    58127 *
    59128 */
     129#define SYNCHELP_WRITE_DEBUG(n) {\
     130  __synchelp_write_n = Converter::intToByteArray( n, data+__synchelp_write_i, maxLength-__synchelp_write_i ); \
     131  assert( __synchelp_write_n == INTSIZE ); \
     132  __synchelp_write_i += __synchelp_write_n; \
     133}
     134
     135#define SYNCHELP_READ_DEBUG(n) {  \
     136  int nn; \
     137  __synchelp_read_n = Converter::byteArrayToInt( data+__synchelp_read_i, &nn );  \
     138  assert( __synchelp_read_n == INTSIZE ); \
     139  if ( n != nn ) { \
     140    PRINTF(1)("Check your code! read/writes not in right order! read %d instead of %d\n", nn, n); \
     141    assert( false ); \
     142  } \
     143  __synchelp_read_i += __synchelp_read_n; \
     144}
     145
    60146#define SYNCHELP_WRITE_BEGIN()    int __synchelp_write_i = 0; \
    61147                                  int __synchelp_write_n
    62 #define SYNCHELP_WRITE_INT(i) { __synchelp_write_n = \
     148#define SYNCHELP_WRITE_INT(i,n) { SYNCHELP_WRITE_DEBUG(n); \
     149                                __synchelp_write_n = \
    63150                                Converter::intToByteArray( i, data+__synchelp_write_i, maxLength-__synchelp_write_i ); \
    64151                                assert( __synchelp_write_n == INTSIZE ); \
     
    70157                                __synchelp_write_i += __synchelp_write_n; \
    71158}
    72 #define SYNCHELP_WRITE_FLOAT(f) { __synchelp_write_n = \
     159#define SYNCHELP_WRITE_FLOAT(f,n) { SYNCHELP_WRITE_DEBUG(n); \
     160                                __synchelp_write_n = \
    73161                                Converter::floatToByteArray( f, data+__synchelp_write_i, maxLength-__synchelp_write_i ); \
    74162                                assert( __synchelp_write_n == FLOATSIZE ); \
     
    80168                                __synchelp_write_i += __synchelp_write_n; \
    81169}
    82 #define SYNCHELP_WRITE_BYTE(b) { \
     170#define SYNCHELP_WRITE_BYTE(b,n) { SYNCHELP_WRITE_DEBUG(n); \
     171                                \
    83172                                if (maxLength - __synchelp_write_i < 1) \
    84173{ \
     
    89178                                __synchelp_write_i++; \
    90179}
    91 #define SYNCHELP_WRITE_STRING(s) { if (s!=NULL) {\
     180#define SYNCHELP_WRITE_STRING(s,n) { SYNCHELP_WRITE_DEBUG(n); \
     181                                if (s!=NULL) {\
    92182                                __synchelp_write_n = \
    93183                                Converter::stringToByteArray( s, data+__synchelp_write_i, strlen(s), maxLength-__synchelp_write_i ); \
     
    105195}
    106196#define SYNCHELP_WRITE_N        __synchelp_write_i
    107 #define SYNCHELP_WRITE_FKT(f)   { \
     197#define SYNCHELP_WRITE_FKT(f,n)   { \
    108198                                  __synchelp_write_i += \
    109199                                  f( data+__synchelp_write_i, maxLength-__synchelp_write_i ); \
     
    114204                                  int __synchelp_read_n
    115205
    116 #define SYNCHELP_READ_INT(i)       { \
     206#define SYNCHELP_READ_INT(i,n)       { SYNCHELP_READ_DEBUG(n); \
    117207                                    if ( length-__synchelp_read_i < INTSIZE ) \
    118208{ \
     
    124214                                    __synchelp_read_i += __synchelp_read_n; \
    125215}
    126 #define SYNCHELP_READ_FLOAT(f)    { \
     216#define SYNCHELP_READ_FLOAT(f,n)    { SYNCHELP_READ_DEBUG(n); \
    127217                                    if ( length-__synchelp_read_i < FLOATSIZE ) \
    128218{ \
     
    134224                                    __synchelp_read_i += __synchelp_read_n; \
    135225}
    136 #define SYNCHELP_READ_STRING(s,l)    { \
     226#define SYNCHELP_READ_STRING(s,l,n)    {SYNCHELP_READ_DEBUG(n); \
    137227                                    __synchelp_read_n = Converter::byteArrayToString( data+__synchelp_read_i, s, l );  \
    138228                                    assert( __synchelp_read_n == strlen(s)+INTSIZE ) ;\
     
    144234                                    __synchelp_read_i += __synchelp_read_n; \
    145235}
    146 #define SYNCHELP_READ_STRINGM(s)    { \
     236#define SYNCHELP_READ_STRINGM(s,n)    { SYNCHELP_READ_DEBUG(n); \
    147237                                    __synchelp_read_n = Converter::byteArrayToStringM( data+__synchelp_read_i, s );  \
    148238                                    assert( __synchelp_read_n == strlen(s)+INTSIZE ) ;\
     
    154244                                    __synchelp_read_i += __synchelp_read_n; \
    155245}
    156 #define SYNCHELP_READ_BYTE(b)      { \
     246#define SYNCHELP_READ_BYTE(b,n)      { SYNCHELP_READ_DEBUG(n); \
    157247                                    if ( length-__synchelp_read_i < 1 ) \
    158248{ \
     
    163253                                    __synchelp_read_i ++;  \
    164254}
    165 #define SYNCHELP_READ_FKT(f)   { \
     255#define SYNCHELP_READ_FKT(f,n)   { SYNCHELP_READ_DEBUG(n); \
    166256                                  __synchelp_read_i += \
    167257                                  f( data+__synchelp_read_i, length-__synchelp_read_i, sender); \
    168258                                  }
     259#define SYNCHELP_READ_REMAINING() ( length-__synchelp_read_i )
     260#define SYNCHELP_READ_NEXTBYTE() ( data[__synchelp_read_i] )
    169261#define SYNCHELP_READ_N           __synchelp_read_i
    170262
Note: See TracChangeset for help on using the changeset viewer.