sys_session.h 27 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644
  1. /*
  2. ===========================================================================
  3. Doom 3 BFG Edition GPL Source Code
  4. Copyright (C) 1993-2012 id Software LLC, a ZeniMax Media company.
  5. This file is part of the Doom 3 BFG Edition GPL Source Code ("Doom 3 BFG Edition Source Code").
  6. Doom 3 BFG Edition Source Code is free software: you can redistribute it and/or modify
  7. it under the terms of the GNU General Public License as published by
  8. the Free Software Foundation, either version 3 of the License, or
  9. (at your option) any later version.
  10. Doom 3 BFG Edition Source Code 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. You should have received a copy of the GNU General Public License
  15. along with Doom 3 BFG Edition Source Code. If not, see <http://www.gnu.org/licenses/>.
  16. In addition, the Doom 3 BFG Edition Source Code is also subject to certain additional terms. You should have received a copy of these additional terms immediately following the terms and conditions of the GNU General Public License which accompanied the Doom 3 BFG Edition Source Code. If not, please request a copy in writing from id Software at the address below.
  17. If you have questions concerning this license or the applicable additional terms, you may contact in writing id Software LLC, c/o ZeniMax Media Inc., Suite 120, Rockville, Maryland 20850 USA.
  18. ===========================================================================
  19. */
  20. #ifndef __SYS_SESSION_H__
  21. #define __SYS_SESSION_H__
  22. #include "../framework/Serializer.h"
  23. #include "sys_localuser.h"
  24. typedef uint8 peerMask_t;
  25. static const int MAX_PLAYERS = 8;
  26. static const int MAX_REDUNDANT_CMDS = 3;
  27. static const int MAX_LOCAL_PLAYERS = 2;
  28. static const int MAX_INPUT_DEVICES = 4;
  29. enum matchFlags_t {
  30. MATCH_STATS = BIT( 0 ), // Match will upload leaderboard/achievement scores
  31. MATCH_ONLINE = BIT( 1 ), // Match will require users to be online
  32. MATCH_RANKED = BIT( 2 ), // Match will affect rank
  33. MATCH_PRIVATE = BIT( 3 ), // Match will NOT be searchable through FindOrCreateMatch
  34. MATCH_INVITE_ONLY = BIT( 4 ), // Match visible through invite only
  35. MATCH_REQUIRE_PARTY_LOBBY = BIT( 5 ), // This session uses a party lobby
  36. MATCH_PARTY_INVITE_PLACEHOLDER = BIT( 6 ), // Party is never shown in the UI, it's simply used as a placeholder for invites
  37. MATCH_JOIN_IN_PROGRESS = BIT( 7 ), // Join in progress supported for this match
  38. };
  39. ID_INLINE bool MatchTypeIsOnline( uint8 matchFlags ) { return ( matchFlags & MATCH_ONLINE ) ? true : false; }
  40. ID_INLINE bool MatchTypeIsLocal( uint8 matchFlags ) { return !MatchTypeIsOnline( matchFlags ); }
  41. ID_INLINE bool MatchTypeIsPrivate( uint8 matchFlags ) { return ( matchFlags & MATCH_PRIVATE ) ? true : false; }
  42. ID_INLINE bool MatchTypeIsRanked( uint8 matchFlags ) { return ( matchFlags & MATCH_RANKED ) ? true : false; }
  43. ID_INLINE bool MatchTypeHasStats( uint8 matchFlags ) { return ( matchFlags & MATCH_STATS ) ? true : false; }
  44. ID_INLINE bool MatchTypeInviteOnly( uint8 matchFlags ) { return ( matchFlags & MATCH_INVITE_ONLY ) ? true : false; }
  45. ID_INLINE bool MatchTypeIsSearchable( uint8 matchFlags ) { return !MatchTypeIsPrivate( matchFlags ); }
  46. ID_INLINE bool MatchTypeIsJoinInProgress( uint8 matchFlags ){ return ( matchFlags & MATCH_JOIN_IN_PROGRESS ) ? true : false; }
  47. class idCompressor;
  48. class idLeaderboardSubmission;
  49. class idLeaderboardQuery;
  50. class idSignInManagerBase;
  51. class idPlayerProfile;
  52. class idGameSpawnInfo;
  53. class idSaveLoadParms;
  54. class idSaveGameManager;
  55. class idLocalUser;
  56. class idDedicatedServerSearch;
  57. class idAchievementSystem;
  58. class idLeaderboardCallback;
  59. struct leaderboardDefinition_t;
  60. struct column_t;
  61. const int8 GAME_MODE_RANDOM = -1;
  62. const int8 GAME_MODE_SINGLEPLAYER = -2;
  63. const int8 GAME_MAP_RANDOM = -1;
  64. const int8 GAME_MAP_SINGLEPLAYER = -2;
  65. const int8 GAME_EPISODE_UNKNOWN = -1;
  66. const int8 GAME_SKILL_DEFAULT = -1;
  67. const int DefaultPartyFlags = MATCH_JOIN_IN_PROGRESS | MATCH_ONLINE;
  68. const int DefaultPublicGameFlags = MATCH_JOIN_IN_PROGRESS | MATCH_REQUIRE_PARTY_LOBBY | MATCH_RANKED | MATCH_STATS;
  69. const int DefaultPrivateGameFlags = MATCH_JOIN_IN_PROGRESS | MATCH_REQUIRE_PARTY_LOBBY | MATCH_PRIVATE;
  70. /*
  71. ================================================
  72. idMatchParameters
  73. ================================================
  74. */
  75. class idMatchParameters {
  76. public:
  77. idMatchParameters() :
  78. numSlots( MAX_PLAYERS ),
  79. gameMode( GAME_MODE_RANDOM ),
  80. gameMap( GAME_MAP_RANDOM ),
  81. gameEpisode( GAME_EPISODE_UNKNOWN ),
  82. gameSkill( GAME_SKILL_DEFAULT ),
  83. matchFlags( 0 )
  84. {}
  85. void Write( idBitMsg & msg ) { idSerializer s( msg, true ); Serialize( s ); }
  86. void Read( idBitMsg & msg ) { idSerializer s( msg, false ); Serialize( s ); }
  87. void Serialize( idSerializer & serializer ) {
  88. serializer.Serialize( gameMode );
  89. serializer.Serialize( gameMap );
  90. serializer.Serialize( gameEpisode );
  91. serializer.Serialize( gameSkill );
  92. serializer.Serialize( numSlots );
  93. serializer.Serialize( matchFlags );
  94. serializer.SerializeString( mapName );
  95. serverInfo.Serialize( serializer );
  96. }
  97. uint8 numSlots;
  98. int8 gameMode;
  99. int8 gameMap;
  100. int8 gameEpisode; // Episode for doom classic support.
  101. int8 gameSkill; // Skill for doom classic support.
  102. uint8 matchFlags;
  103. idStr mapName; // This is only used for SP (gameMap == GAME_MAP_SINGLEPLAYER)
  104. idDict serverInfo;
  105. };
  106. /*
  107. ================================================
  108. serverInfo_t
  109. Results from calling ListServers/ServerInfo for game browser / system link.
  110. ================================================
  111. */
  112. struct serverInfo_t {
  113. serverInfo_t() :
  114. gameMode( GAME_MODE_RANDOM ),
  115. gameMap( GAME_MAP_RANDOM ),
  116. joinable(),
  117. numPlayers(),
  118. maxPlayers()
  119. {}
  120. void Write( idBitMsg & msg ) { idSerializer s( msg, true ); Serialize( s ); }
  121. void Read( idBitMsg & msg ) { idSerializer s( msg, false ); Serialize( s ); }
  122. void Serialize( idSerializer & serializer ) {
  123. serializer.SerializeString( serverName );
  124. serializer.Serialize( gameMode );
  125. serializer.Serialize( gameMap );
  126. SERIALIZE_BOOL( serializer, joinable );
  127. serializer.Serialize( numPlayers );
  128. serializer.Serialize( maxPlayers );
  129. }
  130. idStr serverName;
  131. int8 gameMode;
  132. int8 gameMap;
  133. bool joinable;
  134. int numPlayers;
  135. int maxPlayers;
  136. };
  137. //------------------------
  138. // voiceState_t
  139. //------------------------
  140. enum voiceState_t {
  141. VOICECHAT_STATE_NO_MIC,
  142. VOICECHAT_STATE_MUTED_LOCAL,
  143. VOICECHAT_STATE_MUTED_REMOTE,
  144. VOICECHAT_STATE_MUTED_ALL,
  145. VOICECHAT_STATE_NOT_TALKING,
  146. VOICECHAT_STATE_TALKING,
  147. VOICECHAT_STATE_TALKING_GLOBAL,
  148. NUM_VOICECHAT_STATE
  149. };
  150. //------------------------
  151. // voiceStateDisplay_t
  152. //------------------------
  153. enum voiceStateDisplay_t {
  154. VOICECHAT_DISPLAY_NONE,
  155. VOICECHAT_DISPLAY_NOTTALKING,
  156. VOICECHAT_DISPLAY_TALKING,
  157. VOICECHAT_DISPLAY_TALKING_GLOBAL,
  158. VOICECHAT_DISPLAY_MUTED,
  159. VOICECHAT_DISPLAY_MAX
  160. };
  161. static const int QOS_RESULT_CRAPPY = 200;
  162. static const int QOS_RESULT_WEAK = 100;
  163. static const int QOS_RESULT_GOOD = 50;
  164. static const int QOS_RESULT_GREAT = 0;
  165. //------------------------
  166. // qosState_t
  167. //------------------------
  168. enum qosState_t {
  169. QOS_STATE_CRAPPY = 1,
  170. QOS_STATE_WEAK,
  171. QOS_STATE_GOOD,
  172. QOS_STATE_GREAT,
  173. QOS_STATE_MAX,
  174. };
  175. //------------------------
  176. // leaderboardDisplayError_t
  177. //------------------------
  178. enum leaderboardDisplayError_t {
  179. LEADERBOARD_DISPLAY_ERROR_NONE,
  180. LEADERBOARD_DISPLAY_ERROR_FAILED, // General error occurred
  181. LEADERBOARD_DISPLAY_ERROR_NOT_ONLINE, // No longer online
  182. LEADERBOARD_DISPLAY_ERROR_NOT_RANKED, // Attempting to view a "My Score" leaderboard you aren't ranked on
  183. LEADERBOARD_DISPLAY_ERROR_MAX
  184. };
  185. /*
  186. ================================================
  187. lobbyUserID_t
  188. ================================================
  189. */
  190. struct lobbyUserID_t {
  191. public:
  192. lobbyUserID_t() : lobbyType( 0xFF ) {}
  193. explicit lobbyUserID_t( localUserHandle_t localUser_, byte lobbyType_ ) : localUserHandle( localUser_ ), lobbyType( lobbyType_ ) {}
  194. bool operator == ( const lobbyUserID_t & other ) const {
  195. return localUserHandle == other.localUserHandle && lobbyType == other.lobbyType; // Lobby type must match
  196. }
  197. bool operator != ( const lobbyUserID_t & other ) const {
  198. return !( *this == other );
  199. }
  200. bool operator < ( const lobbyUserID_t & other ) const {
  201. if ( localUserHandle == other.localUserHandle ) {
  202. return lobbyType < other.lobbyType; // Lobby type tie breaker
  203. }
  204. return localUserHandle < other.localUserHandle;
  205. }
  206. bool CompareIgnoreLobbyType( const lobbyUserID_t & other ) const {
  207. return localUserHandle == other.localUserHandle;
  208. }
  209. localUserHandle_t GetLocalUserHandle() const { return localUserHandle; }
  210. byte GetLobbyType() const { return lobbyType; }
  211. bool IsValid() const { return localUserHandle.IsValid() && lobbyType != 0xFF; }
  212. void WriteToMsg( idBitMsg & msg ) {
  213. localUserHandle.WriteToMsg( msg );
  214. msg.WriteByte( lobbyType );
  215. }
  216. void ReadFromMsg( const idBitMsg & msg ) {
  217. localUserHandle.ReadFromMsg( msg );
  218. lobbyType = msg.ReadByte();
  219. }
  220. void Serialize( idSerializer & ser );
  221. private:
  222. localUserHandle_t localUserHandle;
  223. byte lobbyType;
  224. };
  225. /*
  226. ================================================
  227. idLobbyBase
  228. ================================================
  229. */
  230. class idLobbyBase {
  231. public:
  232. // General lobby functionality
  233. virtual bool IsHost() const = 0;
  234. virtual bool IsPeer() const = 0;
  235. virtual bool HasActivePeers() const = 0;
  236. virtual int GetNumLobbyUsers() const = 0;
  237. virtual int GetNumActiveLobbyUsers() const = 0;
  238. virtual bool IsLobbyUserConnected( int index ) const = 0;
  239. virtual lobbyUserID_t GetLobbyUserIdByOrdinal( int userIndex ) const = 0;
  240. virtual int GetLobbyUserIndexFromLobbyUserID( lobbyUserID_t lobbyUserID ) const = 0;
  241. virtual void SendReliable( int type, idBitMsg & msg, bool callReceiveReliable = true, peerMask_t sessionUserMask = MAX_UNSIGNED_TYPE( peerMask_t ) ) = 0;
  242. virtual void SendReliableToLobbyUser( lobbyUserID_t lobbyUserID, int type, idBitMsg & msg ) = 0;
  243. virtual void SendReliableToHost( int type, idBitMsg & msg ) = 0;
  244. // Lobby user access
  245. virtual const char * GetLobbyUserName( lobbyUserID_t lobbyUserID ) const = 0;
  246. virtual void KickLobbyUser( lobbyUserID_t lobbyUserID ) = 0;
  247. virtual bool IsLobbyUserValid( lobbyUserID_t lobbyUserID ) const = 0;
  248. virtual bool IsLobbyUserLoaded( lobbyUserID_t lobbyUserID ) const = 0;
  249. virtual bool LobbyUserHasFirstFullSnap( lobbyUserID_t lobbyUserID ) const = 0;
  250. virtual void EnableSnapshotsForLobbyUser( lobbyUserID_t lobbyUserID ) = 0;
  251. virtual int GetLobbyUserSkinIndex( lobbyUserID_t lobbyUserID ) const = 0;
  252. virtual bool GetLobbyUserWeaponAutoReload( lobbyUserID_t lobbyUserID ) const = 0;
  253. virtual bool GetLobbyUserWeaponAutoSwitch( lobbyUserID_t lobbyUserID ) const = 0;
  254. virtual int GetLobbyUserLevel( lobbyUserID_t lobbyUserID ) const = 0;
  255. virtual int GetLobbyUserQoS( lobbyUserID_t lobbyUserID ) const = 0;
  256. virtual int GetLobbyUserTeam( lobbyUserID_t lobbyUserID ) const = 0;
  257. virtual bool SetLobbyUserTeam( lobbyUserID_t lobbyUserID, int teamNumber ) = 0;
  258. virtual int GetLobbyUserPartyToken( lobbyUserID_t lobbyUserID ) const = 0;
  259. virtual idPlayerProfile * GetProfileFromLobbyUser( lobbyUserID_t lobbyUserID ) = 0;
  260. virtual idLocalUser * GetLocalUserFromLobbyUser( lobbyUserID_t lobbyUserID ) = 0;
  261. virtual int GetNumLobbyUsersOnTeam( int teamNumber ) const = 0;
  262. virtual int PeerIndexFromLobbyUser( lobbyUserID_t lobbyUserID ) const = 0;
  263. virtual int GetPeerTimeSinceLastPacket( int peerIndex ) const = 0;
  264. virtual int PeerIndexForHost() const = 0;
  265. virtual lobbyUserID_t AllocLobbyUserSlotForBot( const char * botName ) = 0;
  266. virtual void RemoveBotFromLobbyUserList( lobbyUserID_t lobbyUserID ) = 0;
  267. virtual bool GetLobbyUserIsBot( lobbyUserID_t lobbyUserID ) const = 0;
  268. virtual const char * GetHostUserName() const = 0;
  269. virtual const idMatchParameters & GetMatchParms() const = 0;
  270. virtual bool IsLobbyFull() const = 0;
  271. // Peer access
  272. virtual bool EnsureAllPeersHaveBaseState() = 0;
  273. virtual bool AllPeersInGame() const = 0;
  274. virtual int GetNumConnectedPeers() const = 0;
  275. virtual int GetNumConnectedPeersInGame() const = 0;
  276. virtual int PeerIndexOnHost() const = 0;
  277. virtual bool IsPeerDisconnected( int peerIndex ) const = 0;
  278. // Snapshots
  279. virtual bool AllPeersHaveStaleSnapObj( int objId ) = 0;
  280. virtual bool AllPeersHaveExpectedSnapObj( int objId ) = 0;
  281. virtual void RefreshSnapObj( int objId ) = 0;
  282. virtual void MarkSnapObjDeleted( int objId ) = 0;
  283. virtual void AddSnapObjTemplate( int objID, idBitMsg & msg ) = 0;
  284. // Debugging
  285. virtual void DrawDebugNetworkHUD() const = 0;
  286. virtual void DrawDebugNetworkHUD2() const = 0;
  287. virtual void DrawDebugNetworkHUD_ServerSnapshotMetrics( bool draw ) = 0;
  288. };
  289. /*
  290. ================================================
  291. idSession
  292. ================================================
  293. */
  294. class idSession {
  295. public:
  296. enum sessionState_t {
  297. PRESS_START,
  298. IDLE,
  299. SEARCHING,
  300. CONNECTING,
  301. PARTY_LOBBY,
  302. GAME_LOBBY,
  303. LOADING,
  304. INGAME,
  305. BUSY,
  306. MAX_STATES
  307. };
  308. enum sessionOption_t {
  309. OPTION_LEAVE_WITH_PARTY = BIT( 0 ), // As a party leader, whether or not to drag your party members with you when you leave a game lobby
  310. OPTION_ALL = 0xFFFFFFFF
  311. };
  312. idSession() :
  313. signInManager( NULL ),
  314. saveGameManager( NULL ),
  315. achievementSystem( NULL ),
  316. dedicatedServerSearch( NULL ) { }
  317. virtual ~idSession();
  318. virtual void Initialize() = 0;
  319. virtual void Shutdown() = 0;
  320. virtual void InitializeSoundRelatedSystems() = 0;
  321. virtual void ShutdownSoundRelatedSystems() = 0;
  322. //=====================================================================================================
  323. // Lobby management
  324. //=====================================================================================================
  325. virtual void CreatePartyLobby( const idMatchParameters & parms_ ) = 0;
  326. virtual void FindOrCreateMatch( const idMatchParameters & parms_ ) = 0;
  327. virtual void CreateMatch( const idMatchParameters & parms_ ) = 0;
  328. virtual void CreateGameStateLobby( const idMatchParameters & parms_ ) = 0;
  329. virtual void UpdateMatchParms( const idMatchParameters & parms_ ) = 0;
  330. virtual void UpdatePartyParms( const idMatchParameters & parms_ ) = 0;
  331. virtual void StartMatch() = 0;
  332. virtual void EndMatch( bool premature=false ) = 0; // Meant for host to end match gracefully, go back to lobby, tally scores, etc
  333. virtual void MatchFinished() = 0; // this is for when the game is over before we go back to lobby. Need this incase the host leaves during this time
  334. virtual void QuitMatch() = 0; // Meant for host or peer to quit the match before it ends, will instigate host migration, etc
  335. virtual void QuitMatchToTitle() = 0; // Will forcefully quit the match and return to the title screen.
  336. virtual void SetSessionOption( sessionOption_t option ) = 0;
  337. virtual void ClearSessionOption( sessionOption_t option ) = 0;
  338. virtual sessionState_t GetBackState() = 0;
  339. virtual void Cancel() = 0;
  340. virtual void MoveToPressStart() = 0;
  341. virtual void FinishDisconnect() = 0;
  342. virtual void LoadingFinished() = 0;
  343. virtual bool IsCurrentLobbyMigrating() const = 0;
  344. virtual bool IsLosingConnectionToHost() const = 0;
  345. virtual bool WasMigrationGame() const = 0;
  346. virtual bool ShouldRelaunchMigrationGame() const = 0;
  347. virtual bool WasGameLobbyCoalesced() const = 0;
  348. virtual bool GetMigrationGameData( idBitMsg & msg, bool reading ) = 0;
  349. virtual bool GetMigrationGameDataUser( lobbyUserID_t lobbyUserID, idBitMsg & msg, bool reading ) = 0;
  350. virtual bool GetMatchParamUpdate( int & peer, int & msg ) = 0;
  351. virtual void Pump() = 0;
  352. virtual void ProcessSnapAckQueue() = 0;
  353. virtual void InviteFriends() = 0;
  354. virtual void InviteParty() = 0;
  355. virtual void ShowPartySessions() = 0;
  356. virtual bool IsPlatformPartyInLobby() = 0;
  357. // Lobby user/peer access
  358. // The party and game lobby are the two platform lobbies that notify the backends (Steam/PSN/LIVE of changes)
  359. virtual idLobbyBase & GetPartyLobbyBase() = 0;
  360. virtual idLobbyBase & GetGameLobbyBase() = 0;
  361. // Game state lobby is the lobby used while in-game. It is so the dedicated server can host this lobby
  362. // and have all platform clients join. It does NOT notify the backends of changes, it's purely for the dedicated
  363. // server to be able to host the in-game lobby.
  364. virtual idLobbyBase & GetActingGameStateLobbyBase() = 0;
  365. // GetActivePlatformLobbyBase will return either the game or party lobby, it won't return the game state lobby
  366. // This function is generally used for menus, in-game code should refer to GetActingGameStateLobby
  367. virtual idLobbyBase & GetActivePlatformLobbyBase() = 0;
  368. virtual idLobbyBase & GetLobbyFromLobbyUserID( lobbyUserID_t lobbyUserID ) = 0;
  369. virtual idPlayerProfile * GetProfileFromMasterLocalUser() = 0;
  370. virtual bool ProcessInputEvent( const sysEvent_t * ev ) = 0;
  371. virtual float GetUpstreamDropRate() = 0;
  372. virtual float GetUpstreamQueueRate() = 0;
  373. virtual int GetQueuedBytes() = 0;
  374. virtual int GetLoadingID() = 0;
  375. virtual bool IsAboutToLoad() const = 0;
  376. virtual const char * GetLocalUserName( int i ) const = 0;
  377. virtual sessionState_t GetState() const = 0;
  378. virtual const char * GetStateString() const = 0;
  379. virtual int NumServers() const = 0;
  380. virtual void ListServers( const idCallback & callback ) = 0;
  381. virtual void CancelListServers() = 0;
  382. virtual void ConnectToServer( int i ) = 0;
  383. virtual const serverInfo_t * ServerInfo( int i ) const = 0;
  384. virtual const idList< idStr > * ServerPlayerList( int i ) = 0;
  385. virtual void ShowServerGamerCardUI( int i ) = 0;
  386. virtual void ShowOnlineSignin() = 0;
  387. virtual void DropClient( int peerNum, int lobbyType ) = 0;
  388. virtual void JoinAfterSwap( void * joinID ) = 0;
  389. //=====================================================================================================
  390. // Downloadable Content
  391. //=====================================================================================================
  392. virtual void EnumerateDownloadableContent() = 0;
  393. virtual int GetNumContentPackages() const = 0;
  394. virtual int GetContentPackageID( int contentIndex ) const = 0;
  395. virtual const char * GetContentPackagePath( int contentIndex ) const = 0;
  396. virtual int GetContentPackageIndexForID( int contentID ) const = 0;
  397. virtual void ShowSystemMarketplaceUI() const = 0;
  398. virtual bool GetSystemMarketplaceHasNewContent() const = 0;
  399. virtual void SetSystemMarketplaceHasNewContent( bool hasNewContent ) = 0;
  400. //=====================================================================================================
  401. // Title Storage Vars
  402. //=====================================================================================================
  403. virtual float GetTitleStorageFloat( const char * name, float defaultFloat ) const = 0;
  404. virtual int GetTitleStorageInt( const char * name, int defaultInt ) const = 0;
  405. virtual bool GetTitleStorageBool( const char * name, bool defaultBool ) const = 0;
  406. virtual const char * GetTitleStorageString( const char * name, const char * defaultString ) const = 0;
  407. virtual bool GetTitleStorageFloat( const char * name, float defaultFloat, float & out ) const { out = defaultFloat; return false; }
  408. virtual bool GetTitleStorageInt( const char * name, int defaultInt, int & out ) const { out = defaultInt; return false; }
  409. virtual bool GetTitleStorageBool( const char * name, bool defaultBool, bool & out ) const { out = defaultBool; return false; }
  410. virtual bool GetTitleStorageString( const char * name, const char * defaultString, const char ** out ) const { if ( out != NULL ) { *out = defaultString; } return false; }
  411. virtual bool IsTitleStorageLoaded() = 0;
  412. //=====================================================================================================
  413. // Leaderboard
  414. //=====================================================================================================
  415. virtual void LeaderboardUpload( lobbyUserID_t lobbyUserID, const leaderboardDefinition_t * leaderboard, const column_t * stats, const idFile_Memory * attachment = NULL ) = 0;
  416. virtual void LeaderboardDownload( int sessionUserIndex, const leaderboardDefinition_t * leaderboard, int startingRank, int numRows, const idLeaderboardCallback & callback ) = 0;
  417. virtual void LeaderboardDownloadAttachment( int sessionUserIndex, const leaderboardDefinition_t * leaderboard, int64 attachmentID ) = 0;
  418. virtual void LeaderboardFlush() = 0;
  419. //=====================================================================================================
  420. // Scoring (currently just for TrueSkill)
  421. //=====================================================================================================
  422. virtual void SetLobbyUserRelativeScore( lobbyUserID_t lobbyUserID, int relativeScore, int team ) = 0;
  423. //=====================================================================================================
  424. // Savegames
  425. //
  426. // Default async implementations, saves to a folder, uses game.details file to describe each save.
  427. // Files saved are up to the game and provide through a callback mechanism. If you want to be notified when
  428. // one of these operations have completed, either modify the framework's completedCallback of each of the
  429. // savegame processors or create your own processors and execute with the savegameManager.
  430. //=====================================================================================================
  431. virtual saveGameHandle_t SaveGameSync( const char * name, const saveFileEntryList_t & files, const idSaveGameDetails & description ) = 0;
  432. virtual saveGameHandle_t SaveGameAsync( const char * name, const saveFileEntryList_t & files, const idSaveGameDetails & description ) = 0;
  433. virtual saveGameHandle_t LoadGameSync( const char * name, saveFileEntryList_t & files ) = 0;
  434. virtual saveGameHandle_t EnumerateSaveGamesSync() = 0;
  435. virtual saveGameHandle_t EnumerateSaveGamesAsync() = 0;
  436. virtual saveGameHandle_t DeleteSaveGameSync( const char * name ) = 0;
  437. virtual saveGameHandle_t DeleteSaveGameAsync( const char * name ) = 0;
  438. virtual bool IsSaveGameCompletedFromHandle( const saveGameHandle_t & handle ) const = 0;
  439. virtual void CancelSaveGameWithHandle( const saveGameHandle_t & handle ) = 0;
  440. // Needed for main menu integration
  441. virtual bool IsEnumerating() const = 0;
  442. virtual saveGameHandle_t GetEnumerationHandle() const = 0;
  443. // Returns the known list of savegames, must first enumerate for the savegames ( via session->Enumerate() )
  444. virtual const saveGameDetailsList_t & GetEnumeratedSavegames() const = 0;
  445. // These are on session and not idGame so it can persist across game deallocations
  446. virtual void SetCurrentSaveSlot( const char * slotName ) = 0;
  447. virtual const char * GetCurrentSaveSlot() const = 0;
  448. // Error checking
  449. virtual bool IsDLCAvailable( const char * mapName ) = 0;
  450. virtual bool LoadGameCheckDiscNumber( idSaveLoadParms & parms ) = 0;
  451. //=====================================================================================================
  452. // GamerCard UI
  453. //=====================================================================================================
  454. virtual void ShowLobbyUserGamerCardUI( lobbyUserID_t lobbyUserID ) = 0;
  455. //=====================================================================================================
  456. virtual void UpdateRichPresence() = 0;
  457. virtual void SendUsercmds( idBitMsg & msg ) = 0;
  458. virtual void SendSnapshot( class idSnapShot & ss ) = 0;
  459. virtual int GetInputRouting( int inputRouting[ MAX_INPUT_DEVICES ] );
  460. virtual void UpdateSignInManager() = 0;
  461. idSignInManagerBase & GetSignInManager() { return *signInManager; }
  462. idSaveGameManager & GetSaveGameManager() { return *saveGameManager; }
  463. idAchievementSystem & GetAchievementSystem() { return *achievementSystem; }
  464. bool HasSignInManager() const { return ( signInManager != NULL ); }
  465. bool HasAchievementSystem() const { return ( achievementSystem != NULL ); }
  466. virtual bool IsSystemUIShowing() const = 0;
  467. virtual void SetSystemUIShowing( bool show ) = 0;
  468. //=====================================================================================================
  469. // Voice chat
  470. //=====================================================================================================
  471. virtual voiceState_t GetLobbyUserVoiceState( lobbyUserID_t lobbyUserID ) = 0;
  472. virtual voiceStateDisplay_t GetDisplayStateFromVoiceState( voiceState_t voiceState ) const = 0;
  473. virtual void ToggleLobbyUserVoiceMute( lobbyUserID_t lobbyUserID ) = 0;
  474. virtual void SetActiveChatGroup( int groupIndex ) = 0;
  475. virtual void CheckVoicePrivileges() = 0;
  476. virtual void SetVoiceGroupsToTeams() = 0;
  477. virtual void ClearVoiceGroups() = 0;
  478. //=====================================================================================================
  479. // Bandwidth / QoS checking
  480. //=====================================================================================================
  481. virtual bool StartOrContinueBandwidthChallenge( bool forceStart ) = 0;
  482. virtual void DebugSetPeerSnaprate( int peerIndex, int snapRateMS ) = 0;
  483. virtual float GetIncomingByteRate() = 0;
  484. //=====================================================================================================
  485. // Invites
  486. //=====================================================================================================
  487. virtual void HandleBootableInvite( int64 lobbyId = 0 ) = 0;
  488. virtual void HandleExitspawnInvite( const lobbyConnectInfo_t & connectInfo ) {}
  489. virtual void ClearBootableInvite() = 0;
  490. virtual void ClearPendingInvite() = 0;
  491. virtual bool HasPendingBootableInvite() = 0;
  492. virtual void SetDiscSwapMPInvite( void * parm ) = 0;
  493. virtual void * GetDiscSwapMPInviteParms() = 0;
  494. virtual bool IsDiscSwapMPInviteRequested() const = 0;
  495. //=====================================================================================================
  496. // Notifications
  497. //=====================================================================================================
  498. // This is called when a LocalUser is signed in/out
  499. virtual void OnLocalUserSignin( idLocalUser * user ) = 0;
  500. virtual void OnLocalUserSignout( idLocalUser * user ) = 0;
  501. // This is called when the master LocalUser is signed in/out, these are called after OnLocalUserSignin/out()
  502. virtual void OnMasterLocalUserSignout() = 0;
  503. virtual void OnMasterLocalUserSignin() = 0;
  504. // After a local user has signed in and their profile has loaded
  505. virtual void OnLocalUserProfileLoaded( idLocalUser * user ) = 0;
  506. protected:
  507. idSignInManagerBase * signInManager; // pointer so we can treat dynamically bind platform-specific impl
  508. idSaveGameManager * saveGameManager;
  509. idAchievementSystem * achievementSystem; // pointer so we can treat dynamically bind platform-specific impl
  510. idDedicatedServerSearch * dedicatedServerSearch;
  511. };
  512. /*
  513. ========================
  514. idSession::idGetInputRouting
  515. ========================
  516. */
  517. ID_INLINE int idSession::GetInputRouting( int inputRouting[ MAX_INPUT_DEVICES ] ) {
  518. for ( int i = 0; i < MAX_INPUT_DEVICES; i++ ) {
  519. inputRouting[ i ] = -1;
  520. }
  521. inputRouting[0] = 0;
  522. return 1;
  523. }
  524. extern idSession * session;
  525. #endif // __SYS_SESSION_H__