Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 6331 in orxonox.OLD


Ignore:
Timestamp:
Dec 29, 2005, 5:37:00 PM (18 years ago)
Author:
rennerc
Message:

synchronizeable: writeBytes now returns int
converter: converts now 0.0f without endless loop :D

Location:
branches/network/src
Files:
24 edited

Legend:

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

    r6142 r6331  
    2727#include "glincl.h"
    2828#include "color.h"
     29
     30#include "synchronizeable.h"
    2931
    3032using namespace std;
     
    10031005    return (PNODE_ROTATE_AND_MOVE);
    10041006}
     1007
     1008/**
     1009 * Writes data from network containing information about the state
     1010 * @param data pointer to data
     1011 * @param length length of data
     1012 * @param sender hostID of sender
     1013 */
     1014int PNode::writeState( const byte * data, int length, int sender )
     1015{
     1016  SYNCHELP_READ_BEGIN();
     1017
     1018  char * name;
     1019  SYNCHELP_READ_STRINGM( name );
     1020
     1021  char * parentName = NULL;
     1022  SYNCHELP_READ_STRINGM( parentName );
     1023
     1024  if ( strcmp(parentName, "")==0 )
     1025  {
     1026    setParent( (char*)NULL );
     1027  }
     1028  else
     1029  {
     1030    setParent( parentName );
     1031  }
     1032
     1033  delete[] parentName;
     1034
     1035  int parentMode;
     1036  SYNCHELP_READ_INT( parentMode );
     1037  this->setParentMode((PARENT_MODE)parentMode);
     1038
     1039  if ( strcmp(name, "")==0 )
     1040  {
     1041    this->setName( NULL );
     1042  }
     1043  else
     1044  {
     1045    this->setName( name );
     1046  }
     1047  delete name;
     1048  name = NULL;
     1049
     1050  float f1, f2, f3, f4;
     1051
     1052  SYNCHELP_READ_FLOAT( f1 );
     1053  SYNCHELP_READ_FLOAT( f2 );
     1054  SYNCHELP_READ_FLOAT( f3 );
     1055  this->setRelCoor( f1, f2, f3 );
     1056
     1057  PRINTF(0)("%f %f %f\n", f1, f2, f3);
     1058
     1059  SYNCHELP_READ_FLOAT( f1 );
     1060  SYNCHELP_READ_FLOAT( f2 );
     1061  SYNCHELP_READ_FLOAT( f3 );
     1062  this->setAbsCoor( f1, f2, f3 );
     1063
     1064  PRINTF(0)("%f %f %f\n", f1, f2, f3);
     1065
     1066  SYNCHELP_READ_FLOAT( f1 );
     1067  SYNCHELP_READ_FLOAT( f2 );
     1068  SYNCHELP_READ_FLOAT( f3 );
     1069  SYNCHELP_READ_FLOAT( f4 );
     1070  this->setRelDir( Quaternion( Vector(f2, f3, f4), f1 ) );
     1071
     1072  SYNCHELP_READ_FLOAT( f1 );
     1073  SYNCHELP_READ_FLOAT( f2 );
     1074  SYNCHELP_READ_FLOAT( f3 );
     1075  SYNCHELP_READ_FLOAT( f4 );
     1076  this->setAbsDir( Quaternion( Vector(f2, f3, f4), f1 ) );
     1077
     1078  int n;
     1079  char * childName;
     1080
     1081  SYNCHELP_READ_INT( n );
     1082
     1083  for (int i = 0; i<n; i++)
     1084  {
     1085    SYNCHELP_READ_STRINGM( childName );
     1086    addChild( childName );
     1087    delete childName;
     1088    childName = NULL;
     1089  }
     1090
     1091  return SYNCHELP_READ_N;
     1092}
     1093
     1094/**
     1095 * data copied in data will bee sent to another host
     1096 * @param data pointer to data
     1097 * @param maxLength max length of data
     1098 * @return the number of bytes writen
     1099 */
     1100int PNode::readState( byte * data, int maxLength )
     1101{
     1102  SYNCHELP_WRITE_BEGIN();
     1103
     1104  SYNCHELP_WRITE_STRING( this->getName() );
     1105
     1106  if ( this->parent )
     1107  {
     1108    SYNCHELP_WRITE_STRING( parent->getName() );
     1109  }
     1110  else
     1111  {
     1112    SYNCHELP_WRITE_STRING( "" );
     1113  }
     1114
     1115  SYNCHELP_WRITE_INT( this->parentMode );
     1116
     1117  SYNCHELP_WRITE_FLOAT( this->relCoordinate.x );
     1118  SYNCHELP_WRITE_FLOAT( this->relCoordinate.y );
     1119  SYNCHELP_WRITE_FLOAT( this->relCoordinate.z );
     1120
     1121  PRINTF(0)("%s, %f, %f, %f\n", getClassName(), relCoordinate.x, relCoordinate.y, relCoordinate.z);
     1122
     1123  SYNCHELP_WRITE_FLOAT( this->absCoordinate.x );
     1124  SYNCHELP_WRITE_FLOAT( this->absCoordinate.y );
     1125  SYNCHELP_WRITE_FLOAT( this->absCoordinate.z );
     1126
     1127  PRINTF(0)("%s, %f, %f, %f\n", getClassName(), absCoordinate.x, absCoordinate.y, absCoordinate.z);
     1128
     1129  SYNCHELP_WRITE_FLOAT( this->relDirection.w );
     1130  SYNCHELP_WRITE_FLOAT( this->relDirection.v.x );
     1131  SYNCHELP_WRITE_FLOAT( this->relDirection.v.y );
     1132  SYNCHELP_WRITE_FLOAT( this->relDirection.v.z );
     1133
     1134  SYNCHELP_WRITE_FLOAT( this->absDirection.w );
     1135  SYNCHELP_WRITE_FLOAT( this->absDirection.v.x );
     1136  SYNCHELP_WRITE_FLOAT( this->absDirection.v.y );
     1137  SYNCHELP_WRITE_FLOAT( this->absDirection.v.z );
     1138
     1139  int n = children.size();
     1140  SYNCHELP_WRITE_INT( n );
     1141
     1142  for (std::list<PNode*>::const_iterator it = children.begin(); it!=children.end(); it++)
     1143  {
     1144    SYNCHELP_WRITE_STRING( (*it)->getName() );
     1145  }
     1146  return SYNCHELP_WRITE_N;
     1147}
  • branches/network/src/lib/coord/p_node.h

    r6142 r6331  
    178178  static PARENT_MODE charToParentingMode(const char* parentingMode);
    179179
     180  int       writeState(const byte* data, int length, int sender);
     181  int       readState(byte* data, int maxLength );
    180182
    181183 private:
  • branches/network/src/lib/network/converter.cc

    r6328 r6331  
    317317    return -1;
    318318  }
     319
     320  //handle 0 else function will loop for ever
     321  if ( x == 0 )
     322  {
     323    for ( int i = 0; i<FLOATSIZE; i++)
     324      a[i] = 0;
     325    return FLOATSIZE;
     326  }
     327
    319328  int mantisse = 0;
    320329  int exponent = 128;
     
    376385int Converter::byteArrayToFloat(const byte* a, float* x)
    377386{
     387  //handle 0
     388  for (int i = 0; i<FLOATSIZE; i++)
     389  {
     390    if (a[i]!=0)
     391      break;
     392    if ( i==FLOATSIZE-1 )
     393    {
     394      *x = 0.0f;
     395      return FLOATSIZE;
     396    }
     397  }
     398
     399
    378400  int hmant = a[0] + a[1] * 256 + a[2] * 65536;
    379401  int mantisse = hmant % expmult;
     
    441463  int n = Converter::byteArrayToInt( a, &length );
    442464
     465
    443466  if ( length+1 > maxLength )
    444467  {
  • branches/network/src/lib/network/handshake.cc

    r6190 r6331  
    3737}
    3838
    39 void Handshake::writeBytes( const byte * data, int length, int sender)
     39int Handshake::writeBytes( const byte * data, int length, int sender)
    4040{
    4141  PRINTF(5)("Handshake::writeBytes states = %d %d %d %d (%d)\n", hasState( HS_RECVD_INIT ), hasState( HS_RECVD_VER ), hasState( HS_RECVD_HID ), hasState( HS_COMPLETED ), state);
    4242
     43  SYNCHELP_READ_BEGIN();
     44
    4345  if ( hasState( HS_COMPLETED ) )
    44        return;
     46       return 0;
    4547
    4648  if ( !hasState( HS_RECVD_INIT ) )
     
    5052      PRINTF(0)("initial packet has wrong size %d instead of %d\n", length, _INITIAL_DATA_LENGTH);
    5153      setState( HS_COMPLETED );
    52       return;
     54      return 0;
    5355    }
    5456
     
    5759      PRINTF(0)("initial packed does not match\n");
    5860      setState( HS_COMPLETED );
    59       return;
     61      return length;
    6062    }
    6163
    6264    setState( HS_RECVD_INIT );
    6365    PRINTF(0)("got valid initial packet from client %d\n", clientId);
    64     return;
     66    return length;
    6567  }
    6668
     
    7173      PRINTF(0)("version number packet has wrong size %d instead of %d\n", length, _ORXONOX_VERSION_LENGTH);
    7274      setState( HS_COMPLETED );
    73       return;
     75      return 0;
    7476    }
    7577
     
    7880      PRINTF(0)("versions do not match\n");
    7981      setState( HS_COMPLETED );
    80       return;
     82      return length;
    8183    }
    8284
     
    8486
    8587    PRINTF(0)("client %d's version does match\n", clientId);
    86     return;
     88    return length;
    8789  }
    8890
    8991  if ( !isServer() && hasState( HS_RECVD_VER ) && !hasState( HS_RECVD_HID ) )
    9092  {
    91     if ( length != 2 )
     93    if ( length != INTSIZE+INTSIZE )
    9294    {
    9395      PRINTF(0)("hostID packet has wrong size %d instead of %d\n", length, 1);
    9496      setState( HS_COMPLETED );
    95       return;
     97      return 0;
    9698    }
    9799
     
    99101    setState( HS_RECVD_HID );
    100102    this->isOk = true;
    101     this->newHostId = data[0];
    102     this->newNetworkGameManagerId = data[1];
     103    SYNCHELP_READ_INT( this->newHostId );
     104    SYNCHELP_READ_INT( this->newNetworkGameManagerId );
    103105
    104106    if ( newHostId == 0 )
     
    112114      PRINTF(0)("got my hostID: %d and networkGameManagerId: %d\n", newHostId, newNetworkGameManagerId);
    113115    }
    114     return;
     116    return SYNCHELP_READ_N;
    115117  }
    116118
     
    120122{
    121123  PRINTF(5)("Handshake::readBytes states = %d %d %d %d (%d)\n", hasState( HS_SENT_INIT ), hasState( HS_SENT_VER ), hasState( HS_SENT_HID ), hasState( HS_COMPLETED ), state);
     124
     125  SYNCHELP_WRITE_BEGIN();
    122126
    123127  if ( hasState( HS_COMPLETED ) )
     
    172176      isOk = false;
    173177      //memcpy(data, (byte*)0, 4);
    174       data[0] = 0;
     178      SYNCHELP_WRITE_INT( 0 );
     179      SYNCHELP_WRITE_INT( 0 );
    175180    }
    176181    else
     
    178183      isOk = true;
    179184      //memcpy(data, &clientId, 4);
    180       data[0] = (byte)clientId;
    181       data[1] = (byte)networkGameManagerId;
     185      SYNCHELP_WRITE_INT( clientId );
     186      SYNCHELP_WRITE_INT( networkGameManagerId );
    182187    }
    183188    *reciever = clientId;
    184     return 2;
     189    return SYNCHELP_WRITE_N;
    185190  }
    186191
  • branches/network/src/lib/network/handshake.h

    r6190 r6331  
    4242    inline void       doReject(){ setState(HS_DO_REJECT); }
    4343
    44     virtual void      writeBytes(const byte* data, int length, int sender);
     44    virtual int       writeBytes(const byte* data, int length, int sender);
    4545    virtual int       readBytes(byte* data, int maxLength, int * reciever);
    4646    virtual void      writeDebug() const;
  • branches/network/src/lib/network/network_game_manager.cc

    r6326 r6331  
    4141
    4242  /* set the class id for the base object */
    43   this->setClassID(CL_NETWORK_GAME_MANAGER, "EntityManager");
     43  this->setClassID(CL_NETWORK_GAME_MANAGER, "NetworkGameManager");
    4444
    4545  allOutBuffer.length = 0;
     
    7070
    7171
    72 void NetworkGameManager::writeBytes(const byte* data, int length, int sender)
     72int NetworkGameManager::writeBytes(const byte* data, int length, int sender)
    7373{
    7474  int i = 0;
     
    8686      {
    8787        if ( !handleRequestCreate( i, data, length, sender ) )
    88           return;
     88          return i;
    8989        continue;
    9090      }
     
    9292      {
    9393        if ( !handleRequestRemove( i, data, length, sender ) )
    94           return;
     94          return i;
    9595        continue;
    9696      }
     
    101101      {
    102102        if ( !handleCreateEntity( i, data, length, sender ) )
    103           return;
     103          return i;
    104104        continue;
    105105      }
     
    107107      {
    108108        if ( !handleRemoveEntity( i, data, length, sender ) )
    109           return;
     109          return i;
    110110        continue;
    111111      }
     
    113113      {
    114114        if ( !handleCreateEntityList( i, data, length, sender ) )
    115           return;
     115          return i;
    116116        continue;
    117117      }
     
    119119      {
    120120        if ( !handleRemoveEntityList( i, data, length, sender ) )
    121           return;
     121          return i;
    122122        continue;
    123123      }
     
    125125      {
    126126        if ( !handleYouAreEntity( i, data, length, sender ) )
    127           return;
     127          return i;
    128128        continue;
    129129      }
     
    133133    {
    134134      if ( !handleRequestSync( i, data, length, sender ) )
    135         return;
     135        return i;
    136136      continue;
    137137    }
     
    146146    //if we get her something with data is wrong
    147147    PRINTF(1)("Data is not in the right format! i=%d\n", i);
    148     return;
    149   }
     148    return i;
     149  }
     150
     151  return i;
    150152}
    151153
  • branches/network/src/lib/network/network_game_manager.h

    r6301 r6331  
    6969    { if (!NetworkGameManager::singletonRef) NetworkGameManager::singletonRef = new NetworkGameManager(); return NetworkGameManager::singletonRef; }
    7070
    71     virtual void writeBytes(const byte* data, int length, int sender);
     71    virtual int writeBytes(const byte* data, int length, int sender);
    7272    virtual int readBytes(byte* data, int maxLength, int * reciever);
    7373    virtual void writeDebug() const;
  • branches/network/src/lib/network/network_stream.cc

    r6326 r6331  
    303303        {
    304304          if ( *it && (*it)->getUniqueID()==header.synchronizeableID )
    305             (*it)->writeBytes(upBuffer+sizeof(header), dataLength, i);
     305          {
     306            if ( (*it)->writeBytes(upBuffer+sizeof(header), dataLength, i) != header.length )
     307            {
     308              PRINTF(1)("%s did not read all the data!\n", (*it)->getClassName());
     309              break;
     310            }
     311            continue;
     312          }
    306313        }
    307314
  • branches/network/src/lib/network/synchronizeable.cc

    r6273 r6331  
    5252 *  write data to NetworkStream
    5353 */
    54 void Synchronizeable::writeBytes(const byte* data, int length, int sender)
     54int Synchronizeable::writeBytes(const byte* data, int length, int sender)
    5555{
    5656  PRINTF(5)("Synchronizeable::writeBytes was called\n");
  • branches/network/src/lib/network/synchronizeable.h

    r6285 r6331  
    4242 * SYNCHELP_READ_STRINGM(s)  allocates memory for string! you have to free this after
    4343 * SYNCHELP_READ_BYTE(b)
     44 * SYNCHELP_READ_N
    4445 *
    4546 *
     
    8687                                __synchelp_write_i++; \
    8788}
    88 #define SYNCHELP_WRITE_STRING(s) { __synchelp_write_n = \
     89#define SYNCHELP_WRITE_STRING(s) { if (s!=NULL) \
     90                                __synchelp_write_n = \
    8991                                Converter::stringToByteArray( s, data+__synchelp_write_i, strlen(s), maxLength-__synchelp_write_i ); \
     92                                else \
     93                                __synchelp_write_n = \
     94                                Converter::stringToByteArray( "", data+__synchelp_write_i, strlen(""), maxLength-__synchelp_write_i ); \
    9095                                if ( __synchelp_write_n <= 0) \
    9196{ \
     
    95100                                __synchelp_write_i += __synchelp_write_n; \
    96101}
    97 #define SYNCHELP_WRITE_N __synchelp_write_i
     102#define SYNCHELP_WRITE_N        __synchelp_write_i
     103#define SYNCHELP_WRITE_FKT(f)   { \
     104                                  __synchelp_write_i += \
     105                                  f( data+__synchelp_write_i, maxLength-__synchelp_write_i ); \
     106                                }
    98107
    99108
     
    105114{ \
    106115                                      PRINTF(1)("There is not enough data to read an int\n");  \
    107                                       return; \
     116                                      return 0; \
    108117} \
    109118                                    __synchelp_read_i += Converter::byteArrayToInt( data+__synchelp_read_i, &i );  \
     
    113122{ \
    114123                                      PRINTF(1)("There is not enough data to read a flaot\n");  \
    115                                       return; \
     124                                      return 0; \
    116125} \
    117126                                    __synchelp_read_i += Converter::byteArrayToFloat( data+__synchelp_read_i, &f );  \
     
    122131{ \
    123132                                      PRINTF(1)("There is not enough data to read string\n");  \
    124                                       return; \
     133                                      return 0; \
    125134} \
    126135                                    __synchelp_read_i += __synchelp_read_n; \
     
    131140{ \
    132141                                      PRINTF(1)("There is not enough data to read string\n");  \
    133                                       return; \
     142                                      return 0; \
    134143} \
    135144                                    __synchelp_read_i += __synchelp_read_n; \
     
    139148{ \
    140149                                      PRINTF(1)("There is not enough data to read a byte\n");  \
    141                                       return; \
     150                                      return 0; \
    142151} \
    143152                                    b = data[__synchelp_read_i]; \
    144153                                    __synchelp_read_i ++;  \
    145154}
     155#define SYNCHELP_READ_FKT(f)   { \
     156                                  __synchelp_read_i += \
     157                                  f( data+__synchelp_read_i, length-__synchelp_read_i, sender); \
     158                                  }
     159#define SYNCHELP_READ_N           __synchelp_read_i
    146160
    147161class NetworkStream;
     
    154168    ~Synchronizeable();
    155169
    156     virtual void      writeBytes(const byte* data, int length, int sender);
     170    virtual int       writeBytes(const byte* data, int length, int sender);
    157171    virtual int       readBytes(byte* data, int maxLength, int * reciever);
    158172    virtual void      writeDebug() const;
  • branches/network/src/subprojects/network/read_sync.cc

    r6190 r6331  
    6060 *  write data to Synchronizeable
    6161 */
    62 void ReadSync::writeBytes(const byte* data, int length, int sender)
     62int ReadSync::writeBytes(const byte* data, int length, int sender)
    6363{
    6464  PRINTF(0)("ReadSync: got %i bytes of data\n", length);
  • branches/network/src/subprojects/network/read_sync.h

    r6190 r6331  
    1616    ~ReadSync();
    1717
    18     virtual void writeBytes(const byte* data, int length, int sender);
     18    virtual int writeBytes(const byte* data, int length, int sender);
    1919    virtual int readBytes(byte* data, int maxLength, int * reciever);
    2020
  • branches/network/src/subprojects/network/simple_sync.cc

    r6190 r6331  
    6666 *  write data to Synchronizeable
    6767 */
    68 void SimpleSync::writeBytes(const byte* data, int length, int sender)
     68int SimpleSync::writeBytes(const byte* data, int length, int sender)
    6969{
    7070  PRINTF(0)("SimpleSync: got %i bytes of data\n", length);
  • branches/network/src/subprojects/network/simple_sync.h

    r6190 r6331  
    1616    ~SimpleSync();
    1717
    18     virtual void writeBytes(const byte* data, int length, int sender);
     18    virtual int writeBytes(const byte* data, int length, int sender);
    1919    virtual int readBytes(byte* data, int maxLength, int * reciever);
    2020
  • branches/network/src/subprojects/network/write_sync.cc

    r6190 r6331  
    6666 *  write data to Synchronizeable
    6767 */
    68 void WriteSync::writeBytes(const byte* data, int length, int sender)
     68int WriteSync::writeBytes(const byte* data, int length, int sender)
    6969{
    7070  PRINTF(0)("WriteSync: got %i bytes of data\n", length);
  • branches/network/src/subprojects/network/write_sync.h

    r6190 r6331  
    1616    ~WriteSync();
    1717
    18     virtual void writeBytes(const byte* data, int length, int sender);
     18    virtual int writeBytes(const byte* data, int length, int sender);
    1919    virtual int readBytes(byte* data, int maxLength, int * reciever);
    2020
  • branches/network/src/world_entities/skybox.cc

    r6328 r6331  
    220220}
    221221
    222 void SkyBox::writeBytes( const byte * data, int length, int sender )
     222int SkyBox::writeBytes( const byte * data, int length, int sender )
    223223{
    224224  setRequestedSync( false );
     
    226226
    227227  SYNCHELP_READ_BEGIN();
     228
     229  SYNCHELP_READ_FKT( WorldEntity::writeState );
     230
    228231  SYNCHELP_READ_FLOAT( size );
    229232  if ( textureName )
     
    239242  this->setTextureAndType( textureName, "jpg" );
    240243  this->rebuild();
     244
     245  return SYNCHELP_READ_N;
    241246}
    242247
     
    258263
    259264    SYNCHELP_WRITE_BEGIN();
     265
     266    SYNCHELP_WRITE_FKT( WorldEntity::readState );
     267
    260268    SYNCHELP_WRITE_FLOAT(this->size);
    261269    SYNCHELP_WRITE_STRING(this->textureName);
  • branches/network/src/world_entities/skybox.h

    r6328 r6331  
    4141                   const char* right, const char* front, const char* back);
    4242
    43   virtual void      writeBytes(const byte* data, int length, int sender);
     43  virtual int       writeBytes(const byte* data, int length, int sender);
    4444  virtual int       readBytes(byte* data, int maxLength, int * reciever);
    4545  virtual void      writeDebug() const;
  • branches/network/src/world_entities/terrain.cc

    r6291 r6331  
    319319}
    320320
    321 void Terrain::writeBytes( const byte * data, int length, int sender )
     321int Terrain::writeBytes( const byte * data, int length, int sender )
    322322{
    323323  setRequestedSync( false );
    324324  setIsOutOfSync( false );
    325325
    326   WorldEntity::writeState(data, length, sender);
     326  SYNCHELP_READ_BEGIN();
     327  SYNCHELP_READ_FKT( WorldEntity::writeState );
     328
     329  return SYNCHELP_READ_N;
    327330}
    328331
  • branches/network/src/world_entities/terrain.h

    r6277 r6331  
    3030  virtual ~Terrain();
    3131
    32   virtual void      writeBytes(const byte* data, int length, int sender);
     32  virtual int       writeBytes(const byte* data, int length, int sender);
    3333  virtual int       readBytes(byte* data, int maxLength, int * reciever);
    3434  virtual void      writeDebug() const;
  • branches/network/src/world_entities/weapons/ground_turret.cc

    r6142 r6331  
    1919
    2020#include "factory.h"
     21#include "network_game_manager.h"
    2122#include "load_param.h"
    2223
     
    168169
    169170}
     171
     172/**
     173 * Writes data from network containing information about the state
     174 * @param data pointer to data
     175 * @param length length of data
     176 * @param sender hostID of sender
     177 */
     178int GroundTurret::writeBytes( const byte * data, int length, int sender )
     179{
     180  setRequestedSync( false );
     181  setIsOutOfSync( false );
     182
     183  SYNCHELP_READ_BEGIN();
     184
     185  SYNCHELP_READ_FKT( WorldEntity::writeState );
     186
     187  return SYNCHELP_READ_N;
     188}
     189
     190/**
     191 * data copied in data will bee sent to another host
     192 * @param data pointer to data
     193 * @param maxLength max length of data
     194 * @return the number of bytes writen
     195 */
     196int GroundTurret::readBytes( byte * data, int maxLength, int * reciever )
     197{
     198  SYNCHELP_WRITE_BEGIN();
     199
     200  if ( isOutOfSync() && !requestedSync() && this->getHostID()!=this->getOwner() )
     201  {
     202    (NetworkGameManager::getInstance())->sync( this->getUniqueID(), this->getOwner() );
     203    setRequestedSync( true );
     204  }
     205
     206  int rec = this->getRequestSync();
     207  if ( rec > 0 )
     208  {
     209    *reciever = rec;
     210
     211    SYNCHELP_WRITE_FKT( WorldEntity::readState );
     212
     213  }
     214
     215  *reciever = 0;
     216  return SYNCHELP_WRITE_N;
     217}
  • branches/network/src/world_entities/weapons/ground_turret.h

    r5819 r6331  
    3030  virtual void collidesWith (WorldEntity* entity, const Vector& location);
    3131
     32  virtual int writeBytes(const byte* data, int length, int sender);
     33  virtual int readBytes(byte* data, int maxLength, int * reciever);
     34
    3235 private:
    3336   Weapon *left, *right;
  • branches/network/src/world_entities/world_entity.cc

    r6328 r6331  
    335335 * @param sender hostID of sender
    336336 */
    337 void WorldEntity::writeState( const byte * data, int length, int sender )
     337int WorldEntity::writeState( const byte * data, int length, int sender )
    338338{
    339339  char* modelFileName;
    340340  SYNCHELP_READ_BEGIN();
     341
     342  SYNCHELP_READ_FKT( PNode::writeState );
     343
    341344  SYNCHELP_READ_STRINGM( modelFileName );
    342345  //check if modelFileName is relative to datadir or absolute
     
    350353  }
    351354  delete[] modelFileName;
     355
     356  return SYNCHELP_READ_N;
    352357}
    353358
     
    361366{
    362367  SYNCHELP_WRITE_BEGIN();
     368
     369  SYNCHELP_WRITE_FKT( PNode::readState );
     370
    363371  SYNCHELP_WRITE_STRING( getModel( 0 )->getName() );
    364372  PRINTF(0)("%s\n", getModel( 0 )->getName());
  • branches/network/src/world_entities/world_entity.h

    r6293 r6331  
    7373  std::list<WorldEntity*>::iterator& getEntityIterator() { return this->objectListIterator; }
    7474
    75   virtual void      writeState(const byte* data, int length, int sender);
    76   virtual int       readState(byte* data, int maxLength );
     75  int       writeState(const byte* data, int length, int sender);
     76  int       readState(byte* data, int maxLength );
    7777 protected:
    7878  //  CharacterAttributes*    charAttr;         //!< the character attributes of a world_entity
Note: See TracChangeset for help on using the changeset viewer.