matcher.h 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  1. /*
  2. ** Command & Conquer Generals Zero Hour(tm)
  3. ** Copyright 2025 Electronic Arts Inc.
  4. **
  5. ** This program is free software: you can redistribute it and/or modify
  6. ** it under the terms of the GNU General Public License as published by
  7. ** the Free Software Foundation, either version 3 of the License, or
  8. ** (at your option) any later version.
  9. **
  10. ** This program is distributed in the hope that it will be useful,
  11. ** but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. ** GNU General Public License for more details.
  14. **
  15. ** You should have received a copy of the GNU General Public License
  16. ** along with this program. If not, see <http://www.gnu.org/licenses/>.
  17. */
  18. #ifndef __MATCHER_H__
  19. #define __MATCHER_H__
  20. #ifdef _WIN32
  21. #include <process.h>
  22. #endif
  23. #include <configfile.h>
  24. #include <critsec.h>
  25. #include <threadfac.h>
  26. #include <tcp.h>
  27. #include <cstdarg>
  28. #include <sem4.h>
  29. #include <string>
  30. #include <peer/peer.h>
  31. class MatcherClass
  32. {
  33. public:
  34. MatcherClass();
  35. virtual ~MatcherClass()
  36. {}
  37. virtual void init(void)
  38. {}
  39. virtual void checkMatches(void)
  40. {}
  41. virtual void handleDisconnect( const char *reason )
  42. {}
  43. virtual void handleRoomMessage( const char *nick, const char *message, MessageType messageType )
  44. {}
  45. virtual void handlePlayerMessage( const char *nick, const char *message, MessageType messageType )
  46. {}
  47. virtual void handlePlayerJoined( const char *nick )
  48. {}
  49. virtual void handlePlayerLeft( const char *nick )
  50. {}
  51. virtual void handlePlayerChangedNick( const char *oldNick, const char *newNick )
  52. {}
  53. virtual void handlePlayerEnum( bool success, int gameSpyIndex, const char *nick, int flags )
  54. {}
  55. void handleConnect( bool success );
  56. void handleGroupRoomList( bool success, int groupID, const char *name );
  57. void handleJoin( bool success );
  58. void handleNickError( const char *badNick );
  59. void connectAndLoop( void );
  60. protected:
  61. Wstring getString(const Wstring& key);
  62. Wstring m_baseNick;
  63. std::string m_nick;
  64. int m_profileID;
  65. PEER m_peer;
  66. bool m_connectSuccess;
  67. bool m_joinSuccess;
  68. void readLoop( void );
  69. int done; // 0=no, neg=quit;error, pos=quit;success
  70. bool quiet;
  71. int m_groupID;
  72. bool m_rotateLogs; // check for log rotation in this thread?
  73. time_t m_lastRotation;
  74. };
  75. #endif /* __MATCHER_H__ */