Changeset 6815 in orxonox.OLD for trunk/src/lib/network
- Timestamp:
- Jan 28, 2006, 5:11:51 PM (19 years ago)
- Location:
- trunk/src/lib/network
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/lib/network/handshake.cc
r6753 r6815 95 95 if ( !isServer() && hasState( HS_RECVD_VER ) && !hasState( HS_RECVD_HID ) ) 96 96 { 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 }*/ 103 103 104 104 setState( HS_COMPLETED ); 105 105 setState( HS_RECVD_HID ); 106 106 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 ); 109 109 110 110 if ( newHostId == 0 ) … … 180 180 isOk = false; 181 181 //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); 184 184 } 185 185 else … … 187 187 isOk = true; 188 188 //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 ); 191 191 } 192 192 *reciever = clientId; -
trunk/src/lib/network/network_game_manager.cc
r6737 r6815 167 167 if ( !isServer() && !hasRequestedWorld ) 168 168 { 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; 172 171 hasRequestedWorld = true; 173 return SYNCHELP_WRITE_N;172 return 1; 174 173 } 175 174 -
trunk/src/lib/network/synchronizeable.h
r6753 r6815 20 20 #define STATE_OUTOFSYNC 2 21 21 #define STATE_REQUESTEDSYNC 4 22 23 enum { 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 NWT_SS_VELX, 33 NWT_SS_VELY, 34 NWT_SS_VELZ, 35 36 NWT_HS_HOST_ID, 37 NWT_HS_NGM_ID, 38 39 NWT_PN_BO_WRITESTATE, 40 NWT_PN_PARENTMODE, 41 NWT_PN_COORX, 42 NWT_PN_COORY, 43 NWT_PN_COORZ, 44 NWT_PN_ROTX, 45 NWT_PN_ROTY, 46 NWT_PN_ROTZ, 47 NWT_PN_ROTV, 48 49 NWT_PN_FLAGS, 50 NWT_PN_SCOORX, 51 NWT_PN_SCOORY, 52 NWT_PN_SCOORZ, 53 NWT_PN_SROTX, 54 NWT_PN_SROTY, 55 NWT_PN_SROTZ, 56 NWT_PN_SROTV, 57 58 NWT_BO_NAME, 59 60 NWT_WE_PN_WRITESTATE, 61 NWT_WE_PN_MODELFILENAME, 62 NWT_WE_PN_SCALING, 63 64 NWT_GT_WE_STATE, 65 66 NWT_SB_WE_STATE, 67 NWT_SB_SIZE, 68 NWT_SB_TEXTURENAME, 69 70 NWT_TER_WE_STATE, 71 72 NWT_PU_WE_STATE, 73 74 NWT_TPU_WE_STATE, 75 76 NWT_LPU_WE_STATE, 77 78 NWT_WPU_WE_STATE, 79 80 NWT_PPU_WE_STATE, 81 NWT_PPU_TYPE, 82 NWT_PPU_VALUE, 83 NWT_PPU_MINVALUE, 84 NWT_PPU_MAXVALUE, 85 86 NWT_WAT_STATE, 87 NWT_WAT_WE_STATE, 88 NWT_WAT_SIZEX, 89 NWT_WAT_SIZEY, 90 NWT_WAT_RESX, 91 NWT_WAT_RESY, 92 NWT_WAT_HEIGHT 93 }; 22 94 23 95 … … 58 130 * 59 131 */ 132 #define SYNCHELP_WRITE_DEBUG(n) {\ 133 __synchelp_write_n = Converter::intToByteArray( n, data+__synchelp_write_i, maxLength-__synchelp_write_i ); \ 134 assert( __synchelp_write_n == INTSIZE ); \ 135 __synchelp_write_i += __synchelp_write_n; \ 136 } 137 138 #define SYNCHELP_READ_DEBUG(n) { \ 139 int nn; \ 140 __synchelp_read_n = Converter::byteArrayToInt( data+__synchelp_read_i, &nn ); \ 141 assert( __synchelp_read_n == INTSIZE ); \ 142 if ( n != nn ) { \ 143 PRINTF(1)("Check your code! read/writes not in right order! read %d instead of %d\n", nn, n); \ 144 assert( false ); \ 145 } \ 146 __synchelp_read_i += __synchelp_read_n; \ 147 } 148 60 149 #define SYNCHELP_WRITE_BEGIN() int __synchelp_write_i = 0; \ 61 150 int __synchelp_write_n 62 #define SYNCHELP_WRITE_INT(i) { __synchelp_write_n = \ 151 #define SYNCHELP_WRITE_INT(i,n) { SYNCHELP_WRITE_DEBUG(n); \ 152 __synchelp_write_n = \ 63 153 Converter::intToByteArray( i, data+__synchelp_write_i, maxLength-__synchelp_write_i ); \ 64 154 assert( __synchelp_write_n == INTSIZE ); \ … … 70 160 __synchelp_write_i += __synchelp_write_n; \ 71 161 } 72 #define SYNCHELP_WRITE_FLOAT(f) { __synchelp_write_n = \ 162 #define SYNCHELP_WRITE_FLOAT(f,n) { SYNCHELP_WRITE_DEBUG(n); \ 163 __synchelp_write_n = \ 73 164 Converter::floatToByteArray( f, data+__synchelp_write_i, maxLength-__synchelp_write_i ); \ 74 165 assert( __synchelp_write_n == FLOATSIZE ); \ … … 80 171 __synchelp_write_i += __synchelp_write_n; \ 81 172 } 82 #define SYNCHELP_WRITE_BYTE(b) { \ 173 #define SYNCHELP_WRITE_BYTE(b,n) { SYNCHELP_WRITE_DEBUG(n); \ 174 \ 83 175 if (maxLength - __synchelp_write_i < 1) \ 84 176 { \ … … 89 181 __synchelp_write_i++; \ 90 182 } 91 #define SYNCHELP_WRITE_STRING(s) { if (s!=NULL) {\ 183 #define SYNCHELP_WRITE_STRING(s,n) { SYNCHELP_WRITE_DEBUG(n); \ 184 if (s!=NULL) {\ 92 185 __synchelp_write_n = \ 93 186 Converter::stringToByteArray( s, data+__synchelp_write_i, strlen(s), maxLength-__synchelp_write_i ); \ … … 105 198 } 106 199 #define SYNCHELP_WRITE_N __synchelp_write_i 107 #define SYNCHELP_WRITE_FKT(f ) {\200 #define SYNCHELP_WRITE_FKT(f,n) { SYNCHELP_WRITE_DEBUG(n); \ 108 201 __synchelp_write_i += \ 109 202 f( data+__synchelp_write_i, maxLength-__synchelp_write_i ); \ … … 114 207 int __synchelp_read_n 115 208 116 #define SYNCHELP_READ_INT(i ) {\209 #define SYNCHELP_READ_INT(i,n) { SYNCHELP_READ_DEBUG(n); \ 117 210 if ( length-__synchelp_read_i < INTSIZE ) \ 118 211 { \ … … 124 217 __synchelp_read_i += __synchelp_read_n; \ 125 218 } 126 #define SYNCHELP_READ_FLOAT(f ) {\219 #define SYNCHELP_READ_FLOAT(f,n) { SYNCHELP_READ_DEBUG(n); \ 127 220 if ( length-__synchelp_read_i < FLOATSIZE ) \ 128 221 { \ … … 134 227 __synchelp_read_i += __synchelp_read_n; \ 135 228 } 136 #define SYNCHELP_READ_STRING(s,l ) {\229 #define SYNCHELP_READ_STRING(s,l,n) {SYNCHELP_READ_DEBUG(n); \ 137 230 __synchelp_read_n = Converter::byteArrayToString( data+__synchelp_read_i, s, l ); \ 138 231 assert( __synchelp_read_n == strlen(s)+INTSIZE ) ;\ … … 144 237 __synchelp_read_i += __synchelp_read_n; \ 145 238 } 146 #define SYNCHELP_READ_STRINGM(s ) {\239 #define SYNCHELP_READ_STRINGM(s,n) { SYNCHELP_READ_DEBUG(n); \ 147 240 __synchelp_read_n = Converter::byteArrayToStringM( data+__synchelp_read_i, s ); \ 148 241 assert( __synchelp_read_n == strlen(s)+INTSIZE ) ;\ … … 154 247 __synchelp_read_i += __synchelp_read_n; \ 155 248 } 156 #define SYNCHELP_READ_BYTE(b ) {\249 #define SYNCHELP_READ_BYTE(b,n) { SYNCHELP_READ_DEBUG(n); \ 157 250 if ( length-__synchelp_read_i < 1 ) \ 158 251 { \ … … 163 256 __synchelp_read_i ++; \ 164 257 } 165 #define SYNCHELP_READ_FKT(f ) {\258 #define SYNCHELP_READ_FKT(f,n) { SYNCHELP_READ_DEBUG(n); \ 166 259 __synchelp_read_i += \ 167 260 f( data+__synchelp_read_i, length-__synchelp_read_i, sender); \ 168 261 } 262 #define SYNCHELP_READ_REMAINING() ( length-__synchelp_read_i ) 263 #define SYNCHELP_READ_NEXTBYTE() ( data[__synchelp_read_i] ) 169 264 #define SYNCHELP_READ_N __synchelp_read_i 170 265
Note: See TracChangeset
for help on using the changeset viewer.