Changeset 6331 in orxonox.OLD for branches/network/src/lib/network/synchronizeable.h
- Timestamp:
- Dec 29, 2005, 5:37:00 PM (18 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/network/src/lib/network/synchronizeable.h
r6285 r6331 42 42 * SYNCHELP_READ_STRINGM(s) allocates memory for string! you have to free this after 43 43 * SYNCHELP_READ_BYTE(b) 44 * SYNCHELP_READ_N 44 45 * 45 46 * … … 86 87 __synchelp_write_i++; \ 87 88 } 88 #define SYNCHELP_WRITE_STRING(s) { __synchelp_write_n = \ 89 #define SYNCHELP_WRITE_STRING(s) { if (s!=NULL) \ 90 __synchelp_write_n = \ 89 91 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 ); \ 90 95 if ( __synchelp_write_n <= 0) \ 91 96 { \ … … 95 100 __synchelp_write_i += __synchelp_write_n; \ 96 101 } 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 } 98 107 99 108 … … 105 114 { \ 106 115 PRINTF(1)("There is not enough data to read an int\n"); \ 107 return ; \116 return 0; \ 108 117 } \ 109 118 __synchelp_read_i += Converter::byteArrayToInt( data+__synchelp_read_i, &i ); \ … … 113 122 { \ 114 123 PRINTF(1)("There is not enough data to read a flaot\n"); \ 115 return ; \124 return 0; \ 116 125 } \ 117 126 __synchelp_read_i += Converter::byteArrayToFloat( data+__synchelp_read_i, &f ); \ … … 122 131 { \ 123 132 PRINTF(1)("There is not enough data to read string\n"); \ 124 return ; \133 return 0; \ 125 134 } \ 126 135 __synchelp_read_i += __synchelp_read_n; \ … … 131 140 { \ 132 141 PRINTF(1)("There is not enough data to read string\n"); \ 133 return ; \142 return 0; \ 134 143 } \ 135 144 __synchelp_read_i += __synchelp_read_n; \ … … 139 148 { \ 140 149 PRINTF(1)("There is not enough data to read a byte\n"); \ 141 return ; \150 return 0; \ 142 151 } \ 143 152 b = data[__synchelp_read_i]; \ 144 153 __synchelp_read_i ++; \ 145 154 } 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 146 160 147 161 class NetworkStream; … … 154 168 ~Synchronizeable(); 155 169 156 virtual voidwriteBytes(const byte* data, int length, int sender);170 virtual int writeBytes(const byte* data, int length, int sender); 157 171 virtual int readBytes(byte* data, int maxLength, int * reciever); 158 172 virtual void writeDebug() const;
Note: See TracChangeset
for help on using the changeset viewer.