GameSpy.h 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148
  1. /*
  2. ** Command & Conquer Generals(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. ////////////////////////////////////////////////////////////////////////////////
  19. // //
  20. // (c) 2001-2003 Electronic Arts Inc. //
  21. // //
  22. ////////////////////////////////////////////////////////////////////////////////
  23. // FILE: GameSpy.h //////////////////////////////////////////////////////
  24. // Generals GameSpy stuff
  25. // Author: Matthew D. Campbell, February 2002
  26. #pragma once
  27. #ifndef __GameSpy_H__
  28. #define __GameSpy_H__
  29. #include "GameSpy/Peer/Peer.h"
  30. #include "GameClient/Color.h"
  31. #include "Common/STLTypedefs.h"
  32. class GameSpyGroupRoom
  33. {
  34. public:
  35. GameSpyGroupRoom() { m_name = AsciiString::TheEmptyString; m_groupID = m_numWaiting = m_maxWaiting = m_numGames = m_numPlaying = 0; }
  36. AsciiString m_name;
  37. Int m_groupID;
  38. Int m_numWaiting;
  39. Int m_maxWaiting;
  40. Int m_numGames;
  41. Int m_numPlaying;
  42. };
  43. typedef std::map<Int, GameSpyGroupRoom> GroupRoomMap;
  44. class GameSpyChatInterface : public SubsystemInterface
  45. {
  46. public:
  47. virtual ~GameSpyChatInterface() { };
  48. virtual void init( void ) = 0;
  49. virtual void reset( void ) = 0;
  50. virtual void update( void ) = 0;
  51. virtual Bool isConnected( void ) = 0;
  52. virtual void login(AsciiString loginName, AsciiString password = AsciiString::TheEmptyString, AsciiString email = AsciiString::TheEmptyString) = 0;
  53. virtual void reconnectProfile( void ) = 0;
  54. virtual void disconnectFromChat( void ) = 0;
  55. virtual void UTMRoom( RoomType roomType, const char *key, const char *val, Bool authenticate = FALSE ) = 0;
  56. virtual void UTMPlayer( const char *name, const char *key, const char *val, Bool authenticate = FALSE ) = 0;
  57. virtual void startGame( void ) = 0;
  58. virtual void leaveRoom( RoomType roomType ) = 0;
  59. virtual void setReady( Bool ready ) = 0;
  60. virtual void enumPlayers( RoomType roomType, peerEnumPlayersCallback callback, void *userData ) = 0;
  61. virtual void startListingGames( peerListingGamesCallback callback ) = 0;
  62. virtual void stopListingGames( void ) = 0;
  63. virtual void joinGroupRoom( Int ID ) = 0;
  64. virtual void joinStagingRoom( GServer server, AsciiString password ) = 0;
  65. virtual void createStagingRoom( AsciiString gameName, AsciiString password, Int maxPlayers ) = 0;
  66. virtual void joinBestGroupRoom( void ) = 0;
  67. inline PEER getPeer( void ) { return m_peer; }
  68. inline AsciiString getLoginName( void ) { return m_loginName; }
  69. inline AsciiString getPassword( void ) { return m_password; }
  70. inline GroupRoomMap* getGroupRooms( void ) { return &m_groupRooms; }
  71. inline Int getCurrentGroupRoomID( void ) { return m_currentGroupRoomID; }
  72. inline Bool getUsingProfile( void ) { return m_usingProfiles; }
  73. inline Int getProfileID( void ) { return m_profileID; }
  74. inline void setCurrentGroupRoomID( Int ID ) { m_currentGroupRoomID = ID; }
  75. void clearGroupRoomList(void);
  76. inline Int getNumGroupRooms( void ) { return m_groupRooms.size(); }
  77. protected:
  78. AsciiString m_loginName;
  79. AsciiString m_password;
  80. AsciiString m_email;
  81. Bool m_usingProfiles;
  82. Int m_profileID;
  83. PEER m_peer;
  84. GroupRoomMap m_groupRooms;
  85. Int m_currentGroupRoomID;
  86. };
  87. GameSpyChatInterface *createGameSpyChat( void );
  88. extern GameSpyChatInterface *TheGameSpyChat;
  89. void JoinRoomCallback(PEER peer, PEERBool success,
  90. PEERJoinResult result, RoomType roomType,
  91. void *param); ///< Called when we (fail to) join a room. param is address of Bool to store result
  92. void ListGroupRoomsCallback(PEER peer, PEERBool success,
  93. int groupID, GServer server,
  94. const char * name, int numWaiting,
  95. int maxWaiting, int numGames,
  96. int numPlaying, void * param); ///< Called while listing group rooms
  97. enum GameSpyColors {
  98. GSCOLOR_DEFAULT = 0,
  99. GSCOLOR_CURRENTROOM,
  100. GSCOLOR_ROOM,
  101. GSCOLOR_GAME,
  102. GSCOLOR_PLAYER_NORMAL,
  103. GSCOLOR_PLAYER_OWNER,
  104. GSCOLOR_PLAYER_BUDDY,
  105. GSCOLOR_PLAYER_SELF,
  106. GSCOLOR_CHAT_NORMAL,
  107. GSCOLOR_CHAT_EMOTE,
  108. GSCOLOR_CHAT_OWNER,
  109. GSCOLOR_CHAT_OWNER_EMOTE,
  110. GSCOLOR_CHAT_PRIVATE,
  111. GSCOLOR_CHAT_PRIVATE_EMOTE,
  112. GSCOLOR_CHAT_PRIVATE_OWNER,
  113. GSCOLOR_CHAT_PRIVATE_OWNER_EMOTE,
  114. GSCOLOR_CHAT_BUDDY,
  115. GSCOLOR_CHAT_SELF,
  116. GSCOLOR_ACCEPT_TRUE,
  117. GSCOLOR_ACCEPT_FALSE,
  118. GSCOLOR_MAX
  119. };
  120. extern const Color GameSpyColor[GSCOLOR_MAX];
  121. #endif // __GameSpy_H__