the game where you go into mines and start crafting! but for consoles (forked directly from smartcmd's github)
1#pragma once
2using namespace std;
3#include <vector>
4#include "..\..\..\Minecraft.World\C4JThread.h"
5#include "NetworkPlayerInterface.h"
6#include "PlatformNetworkManagerInterface.h"
7#include "SessionInfo.h"
8
9class CPlatformNetworkManagerStub : public CPlatformNetworkManager
10{
11 friend class CGameNetworkManager;
12public:
13 virtual bool Initialise(CGameNetworkManager *pGameNetworkManager, int flagIndexSize);
14 virtual void Terminate();
15 virtual int GetJoiningReadyPercentage();
16 virtual int CorrectErrorIDS(int IDS);
17
18 virtual void DoWork();
19 virtual int GetPlayerCount();
20 virtual int GetOnlinePlayerCount();
21 virtual int GetLocalPlayerMask(int playerIndex);
22 virtual bool AddLocalPlayerByUserIndex( int userIndex );
23 virtual bool RemoveLocalPlayerByUserIndex( int userIndex );
24 virtual INetworkPlayer *GetLocalPlayerByUserIndex( int userIndex );
25 virtual INetworkPlayer *GetPlayerByIndex(int playerIndex);
26 virtual INetworkPlayer * GetPlayerByXuid(PlayerUID xuid);
27 virtual INetworkPlayer * GetPlayerBySmallId(unsigned char smallId);
28 virtual bool ShouldMessageForFullSession();
29
30 virtual INetworkPlayer *GetHostPlayer();
31 virtual bool IsHost();
32 virtual bool JoinGameFromInviteInfo( int userIndex, int userMask, const INVITE_INFO *pInviteInfo);
33 virtual bool LeaveGame(bool bMigrateHost);
34
35 virtual bool IsInSession();
36 virtual bool IsInGameplay();
37 virtual bool IsReadyToPlayOrIdle();
38 virtual bool IsInStatsEnabledSession();
39 virtual bool SessionHasSpace(unsigned int spaceRequired = 1);
40 virtual void SendInviteGUI(int quadrant);
41 virtual bool IsAddingPlayer();
42
43 virtual void HostGame(int localUsersMask, bool bOnlineGame, bool bIsPrivate, unsigned char publicSlots = MINECRAFT_NET_MAX_PLAYERS, unsigned char privateSlots = 0);
44 virtual int JoinGame(FriendSessionInfo *searchResult, int localUsersMask, int primaryUserIndex );
45 virtual bool SetLocalGame(bool isLocal);
46 virtual bool IsLocalGame() { return m_bIsOfflineGame; }
47 virtual void SetPrivateGame(bool isPrivate);
48 virtual bool IsPrivateGame() { return m_bIsPrivateGame; }
49 virtual bool IsLeavingGame() { return m_bLeavingGame; }
50 virtual void ResetLeavingGame() { m_bLeavingGame = false; }
51
52 virtual void RegisterPlayerChangedCallback(int iPad, void (*callback)(void *callbackParam, INetworkPlayer *pPlayer, bool leaving), void *callbackParam);
53 virtual void UnRegisterPlayerChangedCallback(int iPad, void (*callback)(void *callbackParam, INetworkPlayer *pPlayer, bool leaving), void *callbackParam);
54
55 virtual void HandleSignInChange();
56
57 virtual bool _RunNetworkGame();
58
59private:
60 bool isSystemPrimaryPlayer(IQNetPlayer *pQNetPlayer);
61 virtual bool _LeaveGame(bool bMigrateHost, bool bLeaveRoom);
62 virtual void _HostGame(int dwUsersMask, unsigned char publicSlots = MINECRAFT_NET_MAX_PLAYERS, unsigned char privateSlots = 0);
63 virtual bool _StartGame();
64
65 IQNet * m_pIQNet; // pointer to QNet interface
66
67 HANDLE m_notificationListener;
68
69 vector<IQNetPlayer *> m_machineQNetPrimaryPlayers; // collection of players that we deem to be the main one for that system
70
71 bool m_bLeavingGame;
72 bool m_bLeaveGameOnTick;
73 bool m_migrateHostOnLeave;
74 bool m_bHostChanged;
75
76 bool m_bIsOfflineGame;
77 bool m_bIsPrivateGame;
78 int m_flagIndexSize;
79
80 // This is only maintained by the host, and is not valid on client machines
81 GameSessionData m_hostGameSessionData;
82 CGameNetworkManager *m_pGameNetworkManager;
83public:
84 virtual void UpdateAndSetGameSessionData(INetworkPlayer *pNetworkPlayerLeaving = NULL);
85
86private:
87 // TODO 4J Stu - Do we need to be able to have more than one of these?
88 void (*playerChangedCallback[XUSER_MAX_COUNT])(void *callbackParam, INetworkPlayer *pPlayer, bool leaving);
89 void *playerChangedCallbackParam[XUSER_MAX_COUNT];
90
91 static int RemovePlayerOnSocketClosedThreadProc( void* lpParam );
92 virtual bool RemoveLocalPlayer( INetworkPlayer *pNetworkPlayer );
93
94 // Things for handling per-system flags
95 class PlayerFlags
96 {
97 public:
98 INetworkPlayer *m_pNetworkPlayer;
99 unsigned char *flags;
100 unsigned int count;
101 PlayerFlags(INetworkPlayer *pNetworkPlayer, unsigned int count);
102 ~PlayerFlags();
103 };
104 vector<PlayerFlags *> m_playerFlags;
105 void SystemFlagAddPlayer(INetworkPlayer *pNetworkPlayer);
106 void SystemFlagRemovePlayer(INetworkPlayer *pNetworkPlayer);
107 void SystemFlagReset();
108public:
109 virtual void SystemFlagSet(INetworkPlayer *pNetworkPlayer, int index);
110 virtual bool SystemFlagGet(INetworkPlayer *pNetworkPlayer, int index);
111
112 // For telemetry
113private:
114 float m_lastPlayerEventTimeStart;
115
116public:
117 wstring GatherStats();
118 wstring GatherRTTStats();
119
120private:
121 vector<FriendSessionInfo *> friendsSessions[XUSER_MAX_COUNT];
122 int m_searchResultsCount[XUSER_MAX_COUNT];
123 int m_lastSearchStartTime[XUSER_MAX_COUNT];
124
125 // The results that will be filled in with the current search
126 XSESSION_SEARCHRESULT_HEADER *m_pSearchResults[XUSER_MAX_COUNT];
127 XNQOS *m_pQoSResult[XUSER_MAX_COUNT];
128
129 // The results from the previous search, which are currently displayed in the game
130 XSESSION_SEARCHRESULT_HEADER *m_pCurrentSearchResults[XUSER_MAX_COUNT];
131 XNQOS *m_pCurrentQoSResult[XUSER_MAX_COUNT];
132 int m_currentSearchResultsCount[XUSER_MAX_COUNT];
133
134 int m_lastSearchPad;
135 bool m_bSearchResultsReady;
136 bool m_bSearchPending;
137 LPVOID m_pSearchParam;
138 void (*m_SessionsUpdatedCallback)(LPVOID pParam);
139
140 C4JThread* m_SearchingThread;
141
142 void TickSearch();
143 void SearchForGames();
144 static int SearchForGamesThreadProc( void* lpParameter );
145
146 void SetSearchResultsReady(int resultCount = 0);
147
148 vector<INetworkPlayer *>currentNetworkPlayers;
149 INetworkPlayer *addNetworkPlayer(IQNetPlayer *pQNetPlayer);
150 void removeNetworkPlayer(IQNetPlayer *pQNetPlayer);
151 static INetworkPlayer *getNetworkPlayer(IQNetPlayer *pQNetPlayer);
152
153 virtual void SetSessionTexturePackParentId( int id );
154 virtual void SetSessionSubTexturePackId( int id );
155 virtual void Notify(int ID, ULONG_PTR Param);
156
157public:
158 virtual vector<FriendSessionInfo *> *GetSessionList(int iPad, int localPlayers, bool partyOnly);
159 virtual bool GetGameSessionInfo(int iPad, SessionID sessionId,FriendSessionInfo *foundSession);
160 virtual void SetSessionsUpdatedCallback( void (*SessionsUpdatedCallback)(LPVOID pParam), LPVOID pSearchParam );
161 virtual void GetFullFriendSessionInfo( FriendSessionInfo *foundSession, void (* FriendSessionUpdatedFn)(bool success, void *pParam), void *pParam );
162 virtual void ForceFriendsSessionRefresh();
163
164public:
165 void NotifyPlayerJoined( IQNetPlayer *pQNetPlayer );
166 void NotifyPlayerLeaving(IQNetPlayer* pQNetPlayer);
167
168#ifndef _XBOX
169 void FakeLocalPlayerJoined() { NotifyPlayerJoined(m_pIQNet->GetLocalPlayerByUserIndex(0)); }
170#endif
171};