Changeset 6331 in orxonox.OLD for branches/network/src/lib/network/handshake.cc
- Timestamp:
- Dec 29, 2005, 5:37:00 PM (19 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/network/src/lib/network/handshake.cc
r6190 r6331 37 37 } 38 38 39 voidHandshake::writeBytes( const byte * data, int length, int sender)39 int Handshake::writeBytes( const byte * data, int length, int sender) 40 40 { 41 41 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); 42 42 43 SYNCHELP_READ_BEGIN(); 44 43 45 if ( hasState( HS_COMPLETED ) ) 44 return ;46 return 0; 45 47 46 48 if ( !hasState( HS_RECVD_INIT ) ) … … 50 52 PRINTF(0)("initial packet has wrong size %d instead of %d\n", length, _INITIAL_DATA_LENGTH); 51 53 setState( HS_COMPLETED ); 52 return ;54 return 0; 53 55 } 54 56 … … 57 59 PRINTF(0)("initial packed does not match\n"); 58 60 setState( HS_COMPLETED ); 59 return ;61 return length; 60 62 } 61 63 62 64 setState( HS_RECVD_INIT ); 63 65 PRINTF(0)("got valid initial packet from client %d\n", clientId); 64 return ;66 return length; 65 67 } 66 68 … … 71 73 PRINTF(0)("version number packet has wrong size %d instead of %d\n", length, _ORXONOX_VERSION_LENGTH); 72 74 setState( HS_COMPLETED ); 73 return ;75 return 0; 74 76 } 75 77 … … 78 80 PRINTF(0)("versions do not match\n"); 79 81 setState( HS_COMPLETED ); 80 return ;82 return length; 81 83 } 82 84 … … 84 86 85 87 PRINTF(0)("client %d's version does match\n", clientId); 86 return ;88 return length; 87 89 } 88 90 89 91 if ( !isServer() && hasState( HS_RECVD_VER ) && !hasState( HS_RECVD_HID ) ) 90 92 { 91 if ( length != 2)93 if ( length != INTSIZE+INTSIZE ) 92 94 { 93 95 PRINTF(0)("hostID packet has wrong size %d instead of %d\n", length, 1); 94 96 setState( HS_COMPLETED ); 95 return ;97 return 0; 96 98 } 97 99 … … 99 101 setState( HS_RECVD_HID ); 100 102 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 ); 103 105 104 106 if ( newHostId == 0 ) … … 112 114 PRINTF(0)("got my hostID: %d and networkGameManagerId: %d\n", newHostId, newNetworkGameManagerId); 113 115 } 114 return ;116 return SYNCHELP_READ_N; 115 117 } 116 118 … … 120 122 { 121 123 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(); 122 126 123 127 if ( hasState( HS_COMPLETED ) ) … … 172 176 isOk = false; 173 177 //memcpy(data, (byte*)0, 4); 174 data[0] = 0; 178 SYNCHELP_WRITE_INT( 0 ); 179 SYNCHELP_WRITE_INT( 0 ); 175 180 } 176 181 else … … 178 183 isOk = true; 179 184 //memcpy(data, &clientId, 4); 180 data[0] = (byte)clientId;181 data[1] = (byte)networkGameManagerId;185 SYNCHELP_WRITE_INT( clientId ); 186 SYNCHELP_WRITE_INT( networkGameManagerId ); 182 187 } 183 188 *reciever = clientId; 184 return 2;189 return SYNCHELP_WRITE_N; 185 190 } 186 191
Note: See TracChangeset
for help on using the changeset viewer.