Advertisement
keybode

se2007 SendConnectPacket

Feb 28th, 2015
771
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.73 KB | None | 0 0
  1. void CBaseClientState::SendConnectPacket (int challengeNr, int authProtocol, int keySize, const char *encryptionKey, uint64 unGSSteamID, bool bGSSecure )
  2. {
  3.     COM_TimestampedLog( "SendConnectPacket" );
  4.  
  5.     netadr_t adr;
  6.     char szServerName[MAX_OSPATH];
  7.     const char *CDKey = "NOCDKEY";
  8.    
  9.     Q_strncpy(szServerName, m_szRetryAddress, MAX_OSPATH);
  10.  
  11.     if ( !NET_StringToAdr (szServerName, &adr) )
  12.     {
  13.         ConMsg ("Bad server address (%s)\n", szServerName );
  14.         Disconnect();
  15.         // Host_Disconnect(); MOTODO
  16.         return;
  17.     }
  18.  
  19.     if ( adr.GetPort() == (unsigned short)0 )
  20.     {
  21.         adr.SetPort( PORT_SERVER );
  22.     }
  23.  
  24.     char        msg_buffer[MAX_ROUTABLE_PAYLOAD];
  25.     bf_write    msg( msg_buffer, sizeof(msg_buffer) );
  26.  
  27.     msg.WriteLong( CONNECTIONLESS_HEADER );
  28.     msg.WriteByte( C2S_CONNECT );
  29.     msg.WriteLong( PROTOCOL_VERSION );
  30.     msg.WriteLong( authProtocol );
  31.     msg.WriteLong( challengeNr );
  32.     msg.WriteString( GetClientName() ); // Name
  33.     msg.WriteString( password.GetString() );        // password
  34.  
  35.     switch ( authProtocol )
  36.     {
  37.         // Fall through, bogus protocol type, use CD key hash.
  38.         case PROTOCOL_HASHEDCDKEY:  CDKey = GetCDKeyHash();
  39.                                     msg.WriteString( CDKey );       // cdkey
  40.                                     break;
  41.  
  42.         case PROTOCOL_STEAM:        if (!PrepareSteamConnectResponse( keySize, encryptionKey, unGSSteamID, bGSSecure, adr, msg ))
  43.                                     {
  44.                                         return;
  45.                                     }
  46.                                     break;
  47.  
  48.         default:                    Host_Error( "Unexepected authentication protocol %i!\n", authProtocol );
  49.                                     return;
  50.     }
  51.  
  52.     // Mark time of this attempt for retransmit requests
  53.     m_flConnectTime = net_time;
  54.  
  55.     // remember challengenr for TCP connection
  56.     m_nChallengeNr = challengeNr;
  57.  
  58.     // Send protocol and challenge value
  59.     NET_SendPacket( NULL, m_Socket, adr, msg.GetData(), msg.GetNumBytesWritten() );
  60. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement