Team Fortress 2 Source Code as on 22/4/2020
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

67 lines
1.7 KiB

  1. //========= Copyright Valve Corporation, All rights reserved. ============//
  2. //
  3. // Purpose:
  4. //
  5. // $NoKeywords: $
  6. //=============================================================================
  7. #include "RconMsgHandler.h"
  8. #include "rcon.h"
  9. #include "info.h"
  10. #include "DialogGameInfo.h"
  11. #include "inetapi.h"
  12. #include "proto_oob.h"
  13. extern void v_strncpy(char *dest, const char *src, int bufsize);
  14. //-----------------------------------------------------------------------------
  15. // Purpose: Constructor
  16. //-----------------------------------------------------------------------------
  17. CRconMsgHandlerDetails::CRconMsgHandlerDetails( CRcon *baseobject, HANDLERTYPE type, void *typeinfo /*= NULL*/ )
  18. : CMsgHandler( type, typeinfo )
  19. {
  20. m_pRcon = baseobject;
  21. }
  22. //-----------------------------------------------------------------------------
  23. // Purpose: Process cracked message
  24. //-----------------------------------------------------------------------------
  25. bool CRconMsgHandlerDetails::Process( netadr_t *from, CMsgBuffer *msg )
  26. {
  27. // Skip the control character
  28. //if (!m_pRcon->Challenge() && msg->ReadByte()!=A2C_PRINT)
  29. // return false;
  30. // get response name
  31. const char *str = msg->ReadString();
  32. if ( !str || !str[0] )
  33. return false;
  34. char info[ 2048 ];
  35. v_strncpy( info, str, 2047 );
  36. info[2047] = 0;
  37. if(!_strnicmp(info,"lBad rcon_password",18) )
  38. {
  39. m_pRcon->BadPassword(info+1);
  40. return true;
  41. }
  42. if(m_pRcon->Challenge() )
  43. { // if we know the challenge value pass it to UpdateServer
  44. int challenge = atoi(info+strlen("challenge rcon"));
  45. m_pRcon->UpdateServer(from, challenge, NULL);
  46. }
  47. else // else pass a default value
  48. {
  49. m_pRcon->UpdateServer(from, -1, info+1 );
  50. }
  51. return true;
  52. }