Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
May 10, 2006, 12:11:43 AM (18 years ago)
Author:
patrick
Message:

network: added some comments and found some small bugs

Location:
branches/network/src/lib/network/synchronizeable_var
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • branches/network/src/lib/network/synchronizeable_var/synchronizeable_quaternion.cc

    r7459 r7559  
    4646  int n = 0;
    4747  int res;
    48  
    49   res = Converter::floatToByteArray( vPtrIn->v.x, buf, maxLength - n );
     48
     49  res = Converter::floatToByteArray( vPtrIn->v.x, buf + n, maxLength - n );
    5050  assert( res > 0 );
    5151  n += res;
    52  
    53   res = Converter::floatToByteArray( vPtrIn->v.y, buf, maxLength - n );
     52
     53  res = Converter::floatToByteArray( vPtrIn->v.y, buf + n, maxLength - n );
    5454  assert( res > 0 );
    5555  n += res;
    56  
    57   res = Converter::floatToByteArray( vPtrIn->v.z, buf, maxLength - n );
     56
     57  res = Converter::floatToByteArray( vPtrIn->v.z, buf + n, maxLength - n );
    5858  assert( res > 0 );
    5959  n += res;
    60  
    61   res = Converter::floatToByteArray( vPtrIn->w, buf, maxLength - n );
     60
     61  res = Converter::floatToByteArray( vPtrIn->w, buf +  n, maxLength - n );
    6262  assert( res > 0 );
    6363  n += res;
    64  
     64
    6565  assert( 4*FLOATSIZE == n );
    66  
     66
    6767  return n;
    6868}
     
    7777{
    7878  assert( maxLength >= 4*FLOATSIZE );
    79  
     79
    8080  float x,y,z,w;
    81  
     81
    8282  int res;
    8383  int n = 0;
    84  
     84
    8585  res += Converter::byteArrayToFloat( buf + n, &x );
    8686  assert( res > 0 );
    8787  n += res;
    88  
     88
    8989  res += Converter::byteArrayToFloat( buf + n, &x );
    9090  assert( res > 0 );
    9191  n += res;
    92  
     92
    9393  res += Converter::byteArrayToFloat( buf + n, &x );
    9494  assert( res > 0 );
    9595  n += res;
    96  
     96
    9797  res += Converter::byteArrayToFloat( buf + n, &w );
    9898  assert( res > 0 );
    9999  n += res;
    100  
     100
    101101  *vPtrOut = Quaternion( Vector(x, y, z), w );
    102  
     102
    103103  assert( res == 4*FLOATSIZE );
    104104  return res;
  • branches/network/src/lib/network/synchronizeable_var/synchronizeable_var.cc

    r7459 r7559  
    1818
    1919
     20
    2021/**
    2122 * standard constructor
     
    2627  assert( ptrIn );
    2728  assert( ptrOut );
    28  
     29
    2930  this->ptrIn = ptrIn;
    3031  this->ptrOut = ptrOut;
     
    3233  this->permission = permission;
    3334  this->priority = priority;
    34   this->real_priority = priority;
     35  this->realPriority = priority;
    3536  this->name = name;
    3637}
  • branches/network/src/lib/network/synchronizeable_var/synchronizeable_var.h

    r7508 r7559  
    99#include <string>
    1010#include "netdefs.h"
     11#include <assert.h>
    1112
    1213class SynchronizeableVar {
     
    1516    SynchronizeableVar( void * ptrIn, void * ptrOut, std::string name, int length, int permission = 0, int priority = 0 );
    1617    virtual ~SynchronizeableVar();
    17    
     18
    1819    /**
    1920     * check if synchronizeable wants to be informed on changes
     
    2122     */
    2223    inline bool beWatched(){ return this->bWatched; }
    23    
     24
    2425    /**
    2526     * write var data to byte buffer
     
    2930     */
    3031    virtual int writeToBuf( byte * buf, int maxLength ) = 0;
    31    
     32
    3233    /**
    3334     * read var data from byte buffer
     
    3738     */
    3839    virtual int readFromBuf( byte * buf, int maxLength ) = 0;
    39    
     40
    4041    /**
    4142     * check if writeToBuf will return the same size every time
     
    4344     */
    4445    virtual bool hasStaticSize() = 0;
    45    
     46
    4647    /**
    4748     * get size writeToBuf needs
     
    4950     */
    5051    virtual int getSize(){ return length; }
    51    
     52
    5253    /**
    5354     * check for permission to write
     
    5556     */
    5657    inline bool checkPremission( int permission ){ return (permission & this->permission) != 0; }
    57    
     58
    5859    /**
    5960     * get variable name
     
    6162     */
    6263    inline std::string getName(){ return name; }
    63    
     64
    6465    /**
    6566     * set variable name
     
    6768     */
    6869    inline void setName( std::string name ) { this->name = name; }
    69    
     70
    7071    /**
    7172     * get priority
     
    7374     */
    7475    inline int getPriority() { return this->priority; }
    75    
     76
    7677    /**
    7778     * set priority
     
    7980     */
    8081    inline void setPriority( int p ) { this->priority = p; }
    81    
     82
    8283    /**
    8384     * reset priority to variable specific default value
    8485     */
    85     inline void resetPriority() { this->priority = this->real_priority; }
     86    inline void resetPriority() { this->priority = this->realPriority; }
    8687
    8788
     
    9596    int permission;     //!< who is allowed to change this var
    9697    int priority;       //!< priority assigned to var
    97     int real_priority;  //!< priority assigned to var, increased every time not sent
    98    
    99    
     98    int realPriority;  //!< priority assigned to var, increased every time not sent
     99
     100
    100101    std::string name;    //!< variable name (for debugging)
    101102
  • branches/network/src/lib/network/synchronizeable_var/synchronizeable_vector.cc

    r7459 r7559  
    4747  int n = 0;
    4848  int res;
    49  
    50   res = Converter::floatToByteArray( vPtrIn->x, buf, maxLength - n );
     49
     50  res = Converter::floatToByteArray( vPtrIn->x, buf + n, maxLength - n );
    5151  assert( res > 0 );
    5252  n += res;
    53  
    54   res = Converter::floatToByteArray( vPtrIn->y, buf, maxLength - n );
     53
     54  res = Converter::floatToByteArray( vPtrIn->y, buf + n, maxLength - n );
    5555  assert( res > 0 );
    5656  n += res;
    57  
    58   res = Converter::floatToByteArray( vPtrIn->z, buf, maxLength - n );
     57
     58  res = Converter::floatToByteArray( vPtrIn->z, buf + n, maxLength - n );
    5959  assert( res > 0 );
    6060  n += res;
    61  
     61
    6262  assert( 3*FLOATSIZE == n );
    63  
     63
    6464  return n;
    6565}
     
    7474{
    7575  assert( maxLength >= 3*FLOATSIZE );
    76  
     76
    7777  float x,y,z;
    78  
     78
    7979  int res;
    8080  int n = 0;
    81  
     81
    8282  res += Converter::byteArrayToFloat( buf + n, &x );
    8383  assert( res > 0 );
    8484  n += res;
    85  
     85
    8686  res += Converter::byteArrayToFloat( buf + n, &x );
    8787  assert( res > 0 );
    8888  n += res;
    89  
     89
    9090  res += Converter::byteArrayToFloat( buf + n, &x );
    9191  assert( res > 0 );
    9292  n += res;
    93  
     93
    9494  *vPtrOut = Vector( x, y, z );
    95  
     95
    9696  assert( res == 3*FLOATSIZE );
    9797  return res;
Note: See TracChangeset for help on using the changeset viewer.