forked from cafeberry/cafeberry
Fix X360 Crossplay (#26)
^Reviewed-on: pieeebot/cafeberry#26 Co-authored-by: qloak <realminecart@gmail.com>
This commit is contained in:
@@ -4889,11 +4889,13 @@ void CMinecraftApp::SignInChangeCallback(LPVOID pParam,bool bPrimaryPlayerChange
|
||||
// 4J Stu - On PS4 we can also cause to exit players if they are signed out here, but we shouldn't do that if
|
||||
// we are going to switch to an offline game as it will likely crash due to incompatible parallel processes
|
||||
bool switchToOffline = false;
|
||||
#ifndef _DISABLE_XBLIVE
|
||||
// If it's an online game, and the primary profile is no longer signed into LIVE then we act as if disconnected
|
||||
if( !ProfileManager.IsSignedInLive( ProfileManager.GetLockedProfile() ) && !g_NetworkManager.IsLocalGame() )
|
||||
{
|
||||
switchToOffline = true;
|
||||
}
|
||||
#endif
|
||||
|
||||
//printf("Old: %x, New: %x, Changed: %x\n", m_ulLastSignInData, ulSignInData, changedPlayers);
|
||||
for(unsigned int i = 0; i < XUSER_MAX_COUNT; ++i)
|
||||
@@ -4958,6 +4960,7 @@ void CMinecraftApp::SignInChangeCallback(LPVOID pParam,bool bPrimaryPlayerChange
|
||||
|
||||
g_NetworkManager.HandleSignInChange();
|
||||
}
|
||||
#ifndef _DISABLE_XBLIVE
|
||||
// Some menus require the player to be signed in to live, so if this callback happens and the primary player is
|
||||
// no longer signed in then nav back
|
||||
else if ( pApp->GetLiveLinkRequired() && !ProfileManager.IsSignedInLive( ProfileManager.GetLockedProfile() ) )
|
||||
@@ -4969,6 +4972,7 @@ void CMinecraftApp::SignInChangeCallback(LPVOID pParam,bool bPrimaryPlayerChange
|
||||
pApp->SetAction(iPrimaryPlayer,eAppAction_EthernetDisconnected);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
#if ( defined __PS3__ || defined __ORBIS__ || defined _DURANGO || defined __PSVITA__ )
|
||||
// 4J-JEV: Need to kick of loading of profile data for sub-sign in players.
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
/*
|
||||
base64.cpp and base64.h
|
||||
|
||||
Copyright (C) 2004-2008 René Nyffenegger
|
||||
Copyright (C) 2004-2008 René Nyffenegger
|
||||
|
||||
This source code is provided 'as-is', without any express or implied
|
||||
warranty. In no event will the author be held liable for any damages
|
||||
@@ -21,7 +21,7 @@
|
||||
|
||||
3. This notice may not be removed or altered from any source distribution.
|
||||
|
||||
René Nyffenegger rene.nyffenegger@adp-gmbh.ch
|
||||
René Nyffenegger rene.nyffenegger@adp-gmbh.ch
|
||||
|
||||
*/
|
||||
|
||||
@@ -41,7 +41,7 @@ static inline bool is_base64(unsigned char c) {
|
||||
}
|
||||
|
||||
// 4J ADDED,
|
||||
std::string base64_encode(std::string str)
|
||||
std::string base64_encode(const std::string& str)
|
||||
{
|
||||
return base64_encode( reinterpret_cast<const unsigned char*>(str.c_str()), str.length() );
|
||||
}
|
||||
|
||||
@@ -2,6 +2,6 @@
|
||||
|
||||
#include <string>
|
||||
|
||||
std::string base64_encode(std::string str);
|
||||
std::string base64_encode(const std::string& str);
|
||||
std::string base64_encode(unsigned char const* , unsigned int len);
|
||||
std::string base64_decode(std::string const& s);
|
||||
@@ -100,12 +100,14 @@ void CGameNetworkManager::DoWork()
|
||||
{
|
||||
case XN_LIVE_LINK_STATE_CHANGED:
|
||||
{
|
||||
#ifndef _DISABLE_XBLIVE
|
||||
int iPrimaryPlayer = g_NetworkManager.GetPrimaryPad();
|
||||
bool bConnected = (pNotification->uiParam!=0)?true:false;
|
||||
if((g_NetworkManager.GetLockedProfile()!=-1) && iPrimaryPlayer!=-1 && bConnected == false && g_NetworkManager.IsInSession() )
|
||||
{
|
||||
app.SetAction(iPrimaryPlayer,eAppAction_EthernetDisconnected);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
break;
|
||||
case XN_LIVE_INVITE_ACCEPTED:
|
||||
@@ -782,7 +784,11 @@ int CGameNetworkManager::JoinFromInvite_SignInReturned(void *pParam,bool bContin
|
||||
|
||||
app.DebugPrintf("JoinFromInvite_SignInReturned, iPad %d\n",iPad);
|
||||
// It's possible that the player has not signed in - they can back out
|
||||
#ifndef _DISABLE_XBLIVE
|
||||
if(ProfileManager.IsSignedIn(iPad) && ProfileManager.IsSignedInLive(iPad) )
|
||||
#else
|
||||
if(ProfileManager.IsSignedIn(iPad))
|
||||
#endif
|
||||
{
|
||||
app.DebugPrintf("JoinFromInvite_SignInReturned, passed sign-in tests\n");
|
||||
int localUsersMask = 0;
|
||||
@@ -794,7 +800,9 @@ int CGameNetworkManager::JoinFromInvite_SignInReturned(void *pParam,bool bContin
|
||||
if(ProfileManager.IsSignedIn(index) )
|
||||
{
|
||||
++joiningUsers;
|
||||
#ifndef _DISABLE_XBLIVE
|
||||
if( !ProfileManager.AllowedToPlayMultiplayer(index) ) noPrivileges = true;
|
||||
#endif
|
||||
localUsersMask |= GetLocalPlayerMask( index );
|
||||
}
|
||||
}
|
||||
@@ -890,6 +898,12 @@ bool CGameNetworkManager::IsNetworkThreadRunning()
|
||||
|
||||
int CGameNetworkManager::RunNetworkGameThreadProc( void* lpParameter )
|
||||
{
|
||||
if( g_NetworkManager.m_bNetworkThreadRunning )
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
g_NetworkManager.m_bNetworkThreadRunning = true;
|
||||
|
||||
// Share AABB & Vec3 pools with default (main thread) - should be ok as long as we don't tick the main thread whilst this thread is running
|
||||
AABB::UseDefaultThreadStorage();
|
||||
Vec3::UseDefaultThreadStorage();
|
||||
@@ -897,7 +911,6 @@ int CGameNetworkManager::RunNetworkGameThreadProc( void* lpParameter )
|
||||
Tile::CreateNewThreadStorage();
|
||||
IntCache::CreateNewThreadStorage();
|
||||
|
||||
g_NetworkManager.m_bNetworkThreadRunning = true;
|
||||
bool success = g_NetworkManager._RunNetworkGame(lpParameter);
|
||||
g_NetworkManager.m_bNetworkThreadRunning = false;
|
||||
if( !success)
|
||||
@@ -905,7 +918,7 @@ int CGameNetworkManager::RunNetworkGameThreadProc( void* lpParameter )
|
||||
TexturePack *tPack = Minecraft::GetInstance()->skins->getSelected();
|
||||
while ( tPack->isLoadingData() || (Minecraft::GetInstance()->skins->needsUIUpdate() || ui.IsReloadingSkin()) )
|
||||
{
|
||||
Sleep(1);
|
||||
Sleep(0);
|
||||
}
|
||||
ui.CleanUpSkinReload();
|
||||
if(app.GetDisconnectReason() == DisconnectPacket::eDisconnect_None)
|
||||
@@ -942,7 +955,7 @@ int CGameNetworkManager::ServerThreadProc( void* lpParameter )
|
||||
{
|
||||
while((Minecraft::GetInstance()->skins->needsUIUpdate() || ui.IsReloadingSkin()))
|
||||
{
|
||||
Sleep(1);
|
||||
Sleep(0);
|
||||
}
|
||||
param->levelGen->loadBaseSaveData();
|
||||
}
|
||||
@@ -984,7 +997,7 @@ int CGameNetworkManager::ExitAndJoinFromInviteThreadProc( void* lpParam )
|
||||
|
||||
while( g_NetworkManager.IsInSession() )
|
||||
{
|
||||
Sleep(1);
|
||||
Sleep(0);
|
||||
}
|
||||
|
||||
// Xbox should always be online when receiving invites - on PS3 we need to check & ask the user to sign in
|
||||
@@ -1260,7 +1273,7 @@ int CGameNetworkManager::ChangeSessionTypeThreadProc( void* lpParam )
|
||||
// wait for the current session to end
|
||||
while( g_NetworkManager.IsInSession() )
|
||||
{
|
||||
Sleep(1);
|
||||
Sleep(0);
|
||||
}
|
||||
|
||||
// Reset this flag as the we don't need to know that we only lost the room only from this point onwards, the behaviour is exactly the same
|
||||
@@ -1665,6 +1678,7 @@ void CGameNetworkManager::GameInviteReceived( int userIndex, const INVITE_INFO *
|
||||
{
|
||||
if (ProfileManager.IsSignedIn(i) && (i == ProfileManager.GetPrimaryPad() || isLocalMultiplayerAvailable))
|
||||
{
|
||||
#ifndef _DISABLE_XBLIVE
|
||||
if (isSignedInLive && !ProfileManager.IsSignedInLive(i))
|
||||
{
|
||||
// Record the first non signed in live pad
|
||||
@@ -1672,6 +1686,9 @@ void CGameNetworkManager::GameInviteReceived( int userIndex, const INVITE_INFO *
|
||||
}
|
||||
|
||||
isSignedInLive = isSignedInLive && ProfileManager.IsSignedInLive(i);
|
||||
#else
|
||||
isSignedInLive = true;
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1743,7 +1760,9 @@ void CGameNetworkManager::GameInviteReceived( int userIndex, const INVITE_INFO *
|
||||
if(index==userIndex || pMinecraft->localplayers[index]!=NULL )
|
||||
{
|
||||
++joiningUsers;
|
||||
#ifndef _DISABLE_XBLIVE
|
||||
if( !ProfileManager.AllowedToPlayMultiplayer(index) ) noPrivileges = true;
|
||||
#endif
|
||||
localUsersMask |= GetLocalPlayerMask( index );
|
||||
}
|
||||
}
|
||||
@@ -1898,6 +1917,7 @@ void CGameNetworkManager::HandleInviteWhenInMenus( int userIndex, const INVITE_I
|
||||
if(!app.IsLocalMultiplayerAvailable())
|
||||
#endif
|
||||
{
|
||||
#ifndef _DISABLE_XBLIVE
|
||||
bool noPrivileges=!ProfileManager.AllowedToPlayMultiplayer(userIndex);
|
||||
|
||||
if(noPrivileges)
|
||||
@@ -1908,6 +1928,7 @@ void CGameNetworkManager::HandleInviteWhenInMenus( int userIndex, const INVITE_I
|
||||
}
|
||||
else
|
||||
{
|
||||
#endif
|
||||
ProfileManager.SetLockedProfile(userIndex);
|
||||
ProfileManager.SetPrimaryPad(userIndex);
|
||||
|
||||
@@ -1930,7 +1951,9 @@ void CGameNetworkManager::HandleInviteWhenInMenus( int userIndex, const INVITE_I
|
||||
{
|
||||
app.DebugPrintf( "Failed joining game from invite\n" );
|
||||
}
|
||||
#ifndef _DISABLE_XBLIVE
|
||||
}
|
||||
#endif
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
#include "stdafx.h"
|
||||
#include "stdafx.h"
|
||||
|
||||
#include "NetworkSocketLayer.h"
|
||||
#include "..\..\Common\Network\PlatformNetworkManager.h"
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,171 +1,171 @@
|
||||
#pragma once
|
||||
using namespace std;
|
||||
#include <vector>
|
||||
#include "..\..\..\Minecraft.World\C4JThread.h"
|
||||
#include "NetworkPlayerInterface.h"
|
||||
#include "PlatformNetworkManagerInterface.h"
|
||||
#include "SessionInfo.h"
|
||||
|
||||
class CPlatformNetworkManagerStub : public CPlatformNetworkManager
|
||||
{
|
||||
friend class CGameNetworkManager;
|
||||
public:
|
||||
virtual bool Initialise(CGameNetworkManager *pGameNetworkManager, int flagIndexSize);
|
||||
virtual void Terminate();
|
||||
virtual int GetJoiningReadyPercentage();
|
||||
virtual int CorrectErrorIDS(int IDS);
|
||||
|
||||
virtual void DoWork();
|
||||
virtual int GetPlayerCount();
|
||||
virtual int GetOnlinePlayerCount();
|
||||
virtual int GetLocalPlayerMask(int playerIndex);
|
||||
virtual bool AddLocalPlayerByUserIndex( int userIndex );
|
||||
virtual bool RemoveLocalPlayerByUserIndex( int userIndex );
|
||||
virtual INetworkPlayer *GetLocalPlayerByUserIndex( int userIndex );
|
||||
virtual INetworkPlayer *GetPlayerByIndex(int playerIndex);
|
||||
virtual INetworkPlayer * GetPlayerByXuid(PlayerUID xuid);
|
||||
virtual INetworkPlayer * GetPlayerBySmallId(unsigned char smallId);
|
||||
virtual bool ShouldMessageForFullSession();
|
||||
|
||||
virtual INetworkPlayer *GetHostPlayer();
|
||||
virtual bool IsHost();
|
||||
virtual bool JoinGameFromInviteInfo( int userIndex, int userMask, const INVITE_INFO *pInviteInfo);
|
||||
virtual bool LeaveGame(bool bMigrateHost);
|
||||
|
||||
virtual bool IsInSession();
|
||||
virtual bool IsInGameplay();
|
||||
virtual bool IsReadyToPlayOrIdle();
|
||||
virtual bool IsInStatsEnabledSession();
|
||||
virtual bool SessionHasSpace(unsigned int spaceRequired = 1);
|
||||
virtual void SendInviteGUI(int quadrant);
|
||||
virtual bool IsAddingPlayer();
|
||||
|
||||
virtual void HostGame(int localUsersMask, bool bOnlineGame, bool bIsPrivate, unsigned char publicSlots = MINECRAFT_NET_MAX_PLAYERS, unsigned char privateSlots = 0);
|
||||
virtual int JoinGame(FriendSessionInfo *searchResult, int localUsersMask, int primaryUserIndex );
|
||||
virtual bool SetLocalGame(bool isLocal);
|
||||
virtual bool IsLocalGame() { return m_bIsOfflineGame; }
|
||||
virtual void SetPrivateGame(bool isPrivate);
|
||||
virtual bool IsPrivateGame() { return m_bIsPrivateGame; }
|
||||
virtual bool IsLeavingGame() { return m_bLeavingGame; }
|
||||
virtual void ResetLeavingGame() { m_bLeavingGame = false; }
|
||||
|
||||
virtual void RegisterPlayerChangedCallback(int iPad, void (*callback)(void *callbackParam, INetworkPlayer *pPlayer, bool leaving), void *callbackParam);
|
||||
virtual void UnRegisterPlayerChangedCallback(int iPad, void (*callback)(void *callbackParam, INetworkPlayer *pPlayer, bool leaving), void *callbackParam);
|
||||
|
||||
virtual void HandleSignInChange();
|
||||
|
||||
virtual bool _RunNetworkGame();
|
||||
|
||||
private:
|
||||
bool isSystemPrimaryPlayer(IQNetPlayer *pQNetPlayer);
|
||||
virtual bool _LeaveGame(bool bMigrateHost, bool bLeaveRoom);
|
||||
virtual void _HostGame(int dwUsersMask, unsigned char publicSlots = MINECRAFT_NET_MAX_PLAYERS, unsigned char privateSlots = 0);
|
||||
virtual bool _StartGame();
|
||||
|
||||
IQNet * m_pIQNet; // pointer to QNet interface
|
||||
|
||||
HANDLE m_notificationListener;
|
||||
|
||||
vector<IQNetPlayer *> m_machineQNetPrimaryPlayers; // collection of players that we deem to be the main one for that system
|
||||
|
||||
bool m_bLeavingGame;
|
||||
bool m_bLeaveGameOnTick;
|
||||
bool m_migrateHostOnLeave;
|
||||
bool m_bHostChanged;
|
||||
|
||||
bool m_bIsOfflineGame;
|
||||
bool m_bIsPrivateGame;
|
||||
int m_flagIndexSize;
|
||||
|
||||
// This is only maintained by the host, and is not valid on client machines
|
||||
GameSessionData m_hostGameSessionData;
|
||||
CGameNetworkManager *m_pGameNetworkManager;
|
||||
public:
|
||||
virtual void UpdateAndSetGameSessionData(INetworkPlayer *pNetworkPlayerLeaving = NULL);
|
||||
|
||||
private:
|
||||
// TODO 4J Stu - Do we need to be able to have more than one of these?
|
||||
void (*playerChangedCallback[XUSER_MAX_COUNT])(void *callbackParam, INetworkPlayer *pPlayer, bool leaving);
|
||||
void *playerChangedCallbackParam[XUSER_MAX_COUNT];
|
||||
|
||||
static int RemovePlayerOnSocketClosedThreadProc( void* lpParam );
|
||||
virtual bool RemoveLocalPlayer( INetworkPlayer *pNetworkPlayer );
|
||||
|
||||
// Things for handling per-system flags
|
||||
class PlayerFlags
|
||||
{
|
||||
public:
|
||||
INetworkPlayer *m_pNetworkPlayer;
|
||||
unsigned char *flags;
|
||||
unsigned int count;
|
||||
PlayerFlags(INetworkPlayer *pNetworkPlayer, unsigned int count);
|
||||
~PlayerFlags();
|
||||
};
|
||||
vector<PlayerFlags *> m_playerFlags;
|
||||
void SystemFlagAddPlayer(INetworkPlayer *pNetworkPlayer);
|
||||
void SystemFlagRemovePlayer(INetworkPlayer *pNetworkPlayer);
|
||||
void SystemFlagReset();
|
||||
public:
|
||||
virtual void SystemFlagSet(INetworkPlayer *pNetworkPlayer, int index);
|
||||
virtual bool SystemFlagGet(INetworkPlayer *pNetworkPlayer, int index);
|
||||
|
||||
// For telemetry
|
||||
private:
|
||||
float m_lastPlayerEventTimeStart;
|
||||
|
||||
public:
|
||||
wstring GatherStats();
|
||||
wstring GatherRTTStats();
|
||||
|
||||
private:
|
||||
vector<FriendSessionInfo *> friendsSessions[XUSER_MAX_COUNT];
|
||||
int m_searchResultsCount[XUSER_MAX_COUNT];
|
||||
int m_lastSearchStartTime[XUSER_MAX_COUNT];
|
||||
|
||||
// The results that will be filled in with the current search
|
||||
XSESSION_SEARCHRESULT_HEADER *m_pSearchResults[XUSER_MAX_COUNT];
|
||||
XNQOS *m_pQoSResult[XUSER_MAX_COUNT];
|
||||
|
||||
// The results from the previous search, which are currently displayed in the game
|
||||
XSESSION_SEARCHRESULT_HEADER *m_pCurrentSearchResults[XUSER_MAX_COUNT];
|
||||
XNQOS *m_pCurrentQoSResult[XUSER_MAX_COUNT];
|
||||
int m_currentSearchResultsCount[XUSER_MAX_COUNT];
|
||||
|
||||
int m_lastSearchPad;
|
||||
bool m_bSearchResultsReady;
|
||||
bool m_bSearchPending;
|
||||
LPVOID m_pSearchParam;
|
||||
void (*m_SessionsUpdatedCallback)(LPVOID pParam);
|
||||
|
||||
C4JThread* m_SearchingThread;
|
||||
|
||||
void TickSearch();
|
||||
void SearchForGames();
|
||||
static int SearchForGamesThreadProc( void* lpParameter );
|
||||
|
||||
void SetSearchResultsReady(int resultCount = 0);
|
||||
|
||||
vector<INetworkPlayer *>currentNetworkPlayers;
|
||||
INetworkPlayer *addNetworkPlayer(IQNetPlayer *pQNetPlayer);
|
||||
void removeNetworkPlayer(IQNetPlayer *pQNetPlayer);
|
||||
static INetworkPlayer *getNetworkPlayer(IQNetPlayer *pQNetPlayer);
|
||||
|
||||
virtual void SetSessionTexturePackParentId( int id );
|
||||
virtual void SetSessionSubTexturePackId( int id );
|
||||
virtual void Notify(int ID, ULONG_PTR Param);
|
||||
|
||||
public:
|
||||
virtual vector<FriendSessionInfo *> *GetSessionList(int iPad, int localPlayers, bool partyOnly);
|
||||
virtual bool GetGameSessionInfo(int iPad, SessionID sessionId,FriendSessionInfo *foundSession);
|
||||
virtual void SetSessionsUpdatedCallback( void (*SessionsUpdatedCallback)(LPVOID pParam), LPVOID pSearchParam );
|
||||
virtual void GetFullFriendSessionInfo( FriendSessionInfo *foundSession, void (* FriendSessionUpdatedFn)(bool success, void *pParam), void *pParam );
|
||||
virtual void ForceFriendsSessionRefresh();
|
||||
|
||||
public:
|
||||
void NotifyPlayerJoined( IQNetPlayer *pQNetPlayer );
|
||||
void NotifyPlayerLeaving( IQNetPlayer *pQNetPlayer );
|
||||
|
||||
#ifndef _XBOX
|
||||
void FakeLocalPlayerJoined() { NotifyPlayerJoined(m_pIQNet->GetLocalPlayerByUserIndex(0)); }
|
||||
#endif
|
||||
};
|
||||
#pragma once
|
||||
using namespace std;
|
||||
#include <vector>
|
||||
#include "..\..\..\Minecraft.World\C4JThread.h"
|
||||
#include "NetworkPlayerInterface.h"
|
||||
#include "PlatformNetworkManagerInterface.h"
|
||||
#include "SessionInfo.h"
|
||||
|
||||
class CPlatformNetworkManagerStub : public CPlatformNetworkManager
|
||||
{
|
||||
friend class CGameNetworkManager;
|
||||
public:
|
||||
virtual bool Initialise(CGameNetworkManager *pGameNetworkManager, int flagIndexSize);
|
||||
virtual void Terminate();
|
||||
virtual int GetJoiningReadyPercentage();
|
||||
virtual int CorrectErrorIDS(int IDS);
|
||||
|
||||
virtual void DoWork();
|
||||
virtual int GetPlayerCount();
|
||||
virtual int GetOnlinePlayerCount();
|
||||
virtual int GetLocalPlayerMask(int playerIndex);
|
||||
virtual bool AddLocalPlayerByUserIndex( int userIndex );
|
||||
virtual bool RemoveLocalPlayerByUserIndex( int userIndex );
|
||||
virtual INetworkPlayer *GetLocalPlayerByUserIndex( int userIndex );
|
||||
virtual INetworkPlayer *GetPlayerByIndex(int playerIndex);
|
||||
virtual INetworkPlayer * GetPlayerByXuid(PlayerUID xuid);
|
||||
virtual INetworkPlayer * GetPlayerBySmallId(unsigned char smallId);
|
||||
virtual bool ShouldMessageForFullSession();
|
||||
|
||||
virtual INetworkPlayer *GetHostPlayer();
|
||||
virtual bool IsHost();
|
||||
virtual bool JoinGameFromInviteInfo( int userIndex, int userMask, const INVITE_INFO *pInviteInfo);
|
||||
virtual bool LeaveGame(bool bMigrateHost);
|
||||
|
||||
virtual bool IsInSession();
|
||||
virtual bool IsInGameplay();
|
||||
virtual bool IsReadyToPlayOrIdle();
|
||||
virtual bool IsInStatsEnabledSession();
|
||||
virtual bool SessionHasSpace(unsigned int spaceRequired = 1);
|
||||
virtual void SendInviteGUI(int quadrant);
|
||||
virtual bool IsAddingPlayer();
|
||||
|
||||
virtual void HostGame(int localUsersMask, bool bOnlineGame, bool bIsPrivate, unsigned char publicSlots = MINECRAFT_NET_MAX_PLAYERS, unsigned char privateSlots = 0);
|
||||
virtual int JoinGame(FriendSessionInfo *searchResult, int localUsersMask, int primaryUserIndex );
|
||||
virtual bool SetLocalGame(bool isLocal);
|
||||
virtual bool IsLocalGame() { return m_bIsOfflineGame; }
|
||||
virtual void SetPrivateGame(bool isPrivate);
|
||||
virtual bool IsPrivateGame() { return m_bIsPrivateGame; }
|
||||
virtual bool IsLeavingGame() { return m_bLeavingGame; }
|
||||
virtual void ResetLeavingGame() { m_bLeavingGame = false; }
|
||||
|
||||
virtual void RegisterPlayerChangedCallback(int iPad, void (*callback)(void *callbackParam, INetworkPlayer *pPlayer, bool leaving), void *callbackParam);
|
||||
virtual void UnRegisterPlayerChangedCallback(int iPad, void (*callback)(void *callbackParam, INetworkPlayer *pPlayer, bool leaving), void *callbackParam);
|
||||
|
||||
virtual void HandleSignInChange();
|
||||
|
||||
virtual bool _RunNetworkGame();
|
||||
|
||||
private:
|
||||
bool isSystemPrimaryPlayer(IQNetPlayer *pQNetPlayer);
|
||||
virtual bool _LeaveGame(bool bMigrateHost, bool bLeaveRoom);
|
||||
virtual void _HostGame(int dwUsersMask, unsigned char publicSlots = MINECRAFT_NET_MAX_PLAYERS, unsigned char privateSlots = 0);
|
||||
virtual bool _StartGame();
|
||||
|
||||
IQNet * m_pIQNet; // pointer to QNet interface
|
||||
|
||||
HANDLE m_notificationListener;
|
||||
|
||||
vector<IQNetPlayer *> m_machineQNetPrimaryPlayers; // collection of players that we deem to be the main one for that system
|
||||
|
||||
bool m_bLeavingGame;
|
||||
bool m_bLeaveGameOnTick;
|
||||
bool m_migrateHostOnLeave;
|
||||
bool m_bHostChanged;
|
||||
|
||||
bool m_bIsOfflineGame;
|
||||
bool m_bIsPrivateGame;
|
||||
int m_flagIndexSize;
|
||||
|
||||
// This is only maintained by the host, and is not valid on client machines
|
||||
GameSessionData m_hostGameSessionData;
|
||||
CGameNetworkManager *m_pGameNetworkManager;
|
||||
public:
|
||||
virtual void UpdateAndSetGameSessionData(INetworkPlayer *pNetworkPlayerLeaving = NULL);
|
||||
|
||||
private:
|
||||
// TODO 4J Stu - Do we need to be able to have more than one of these?
|
||||
void (*playerChangedCallback[XUSER_MAX_COUNT])(void *callbackParam, INetworkPlayer *pPlayer, bool leaving);
|
||||
void *playerChangedCallbackParam[XUSER_MAX_COUNT];
|
||||
|
||||
static int RemovePlayerOnSocketClosedThreadProc( void* lpParam );
|
||||
virtual bool RemoveLocalPlayer( INetworkPlayer *pNetworkPlayer );
|
||||
|
||||
// Things for handling per-system flags
|
||||
class PlayerFlags
|
||||
{
|
||||
public:
|
||||
INetworkPlayer *m_pNetworkPlayer;
|
||||
unsigned char *flags;
|
||||
unsigned int count;
|
||||
PlayerFlags(INetworkPlayer *pNetworkPlayer, unsigned int count);
|
||||
~PlayerFlags();
|
||||
};
|
||||
vector<PlayerFlags *> m_playerFlags;
|
||||
void SystemFlagAddPlayer(INetworkPlayer *pNetworkPlayer);
|
||||
void SystemFlagRemovePlayer(INetworkPlayer *pNetworkPlayer);
|
||||
void SystemFlagReset();
|
||||
public:
|
||||
virtual void SystemFlagSet(INetworkPlayer *pNetworkPlayer, int index);
|
||||
virtual bool SystemFlagGet(INetworkPlayer *pNetworkPlayer, int index);
|
||||
|
||||
// For telemetry
|
||||
private:
|
||||
float m_lastPlayerEventTimeStart;
|
||||
|
||||
public:
|
||||
wstring GatherStats();
|
||||
wstring GatherRTTStats();
|
||||
|
||||
private:
|
||||
vector<FriendSessionInfo *> friendsSessions[XUSER_MAX_COUNT];
|
||||
int m_searchResultsCount[XUSER_MAX_COUNT];
|
||||
int m_lastSearchStartTime[XUSER_MAX_COUNT];
|
||||
|
||||
// The results that will be filled in with the current search
|
||||
XSESSION_SEARCHRESULT_HEADER *m_pSearchResults[XUSER_MAX_COUNT];
|
||||
XNQOS *m_pQoSResult[XUSER_MAX_COUNT];
|
||||
|
||||
// The results from the previous search, which are currently displayed in the game
|
||||
XSESSION_SEARCHRESULT_HEADER *m_pCurrentSearchResults[XUSER_MAX_COUNT];
|
||||
XNQOS *m_pCurrentQoSResult[XUSER_MAX_COUNT];
|
||||
int m_currentSearchResultsCount[XUSER_MAX_COUNT];
|
||||
|
||||
int m_lastSearchPad;
|
||||
bool m_bSearchResultsReady;
|
||||
bool m_bSearchPending;
|
||||
LPVOID m_pSearchParam;
|
||||
void (*m_SessionsUpdatedCallback)(LPVOID pParam);
|
||||
|
||||
C4JThread* m_SearchingThread;
|
||||
|
||||
void TickSearch();
|
||||
void SearchForGames();
|
||||
static int SearchForGamesThreadProc( void* lpParameter );
|
||||
|
||||
void SetSearchResultsReady(int resultCount = 0);
|
||||
|
||||
vector<INetworkPlayer *>currentNetworkPlayers;
|
||||
INetworkPlayer *addNetworkPlayer(IQNetPlayer *pQNetPlayer);
|
||||
void removeNetworkPlayer(IQNetPlayer *pQNetPlayer);
|
||||
static INetworkPlayer *getNetworkPlayer(IQNetPlayer *pQNetPlayer);
|
||||
|
||||
virtual void SetSessionTexturePackParentId( int id );
|
||||
virtual void SetSessionSubTexturePackId( int id );
|
||||
virtual void Notify(int ID, ULONG_PTR Param);
|
||||
|
||||
public:
|
||||
virtual vector<FriendSessionInfo *> *GetSessionList(int iPad, int localPlayers, bool partyOnly);
|
||||
virtual bool GetGameSessionInfo(int iPad, SessionID sessionId,FriendSessionInfo *foundSession);
|
||||
virtual void SetSessionsUpdatedCallback( void (*SessionsUpdatedCallback)(LPVOID pParam), LPVOID pSearchParam );
|
||||
virtual void GetFullFriendSessionInfo( FriendSessionInfo *foundSession, void (* FriendSessionUpdatedFn)(bool success, void *pParam), void *pParam );
|
||||
virtual void ForceFriendsSessionRefresh();
|
||||
|
||||
public:
|
||||
void NotifyPlayerJoined( IQNetPlayer *pQNetPlayer );
|
||||
void NotifyPlayerLeaving( IQNetPlayer *pQNetPlayer );
|
||||
|
||||
#ifndef _XBOX
|
||||
void FakeLocalPlayerJoined() { NotifyPlayerJoined(m_pIQNet->GetLocalPlayerByUserIndex(0)); }
|
||||
#endif
|
||||
};
|
||||
|
||||
@@ -600,6 +600,21 @@ void UIScene_JoinMenu::JoinGame(UIScene_JoinMenu* pClass)
|
||||
ui.NavigateToHomeMenu();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
LoadingInputParams *loadingParams = new LoadingInputParams();
|
||||
loadingParams->func = &CGameNetworkManager::RunNetworkGameThreadProc;
|
||||
loadingParams->lpParam = NULL;
|
||||
|
||||
UIFullscreenProgressCompletionData *completionData = new UIFullscreenProgressCompletionData();
|
||||
completionData->bShowBackground = TRUE;
|
||||
completionData->bShowLogo = TRUE;
|
||||
completionData->type = e_ProgressCompletion_CloseAllPlayersUIScenes;
|
||||
completionData->iPad = DEFAULT_XUI_MENU_USER;
|
||||
loadingParams->completionData = completionData;
|
||||
|
||||
ui.NavigateToScene(ProfileManager.GetPrimaryPad(), eUIScene_FullscreenProgress, loadingParams);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -76,7 +76,19 @@ HRESULT CScene_LoadGameSettings::OnInit( XUIMessageInit* pInitData, BOOL& bHandl
|
||||
XuiControlSetText(m_ButtonLoad,app.GetString(IDS_LOAD));
|
||||
XuiControlSetText(m_pTexturePacksList->m_hObj,app.GetString(IDS_DLC_MENU_TEXTUREPACKS));
|
||||
|
||||
#ifndef _DISABLE_XBLIVE
|
||||
#ifndef _DISABLE_XBLIVE
|
||||
#ifndef _DISABLE_XBLIVE
|
||||
m_bMultiplayerAllowed = ProfileManager.IsSignedInLive( m_iPad ) && ProfileManager.AllowedToPlayMultiplayer(m_iPad);
|
||||
#else
|
||||
m_bMultiplayerAllowed = true;
|
||||
#endif
|
||||
#else
|
||||
m_bMultiplayerAllowed = true;
|
||||
#endif
|
||||
#else
|
||||
m_bMultiplayerAllowed = true;
|
||||
#endif
|
||||
// 4J-PB - read the settings for the online flag. We'll only save this setting if the user changed it.
|
||||
bool bGameSetting_Online=(app.GetGameSettings(m_iPad,eGameSetting_Online)!=0);
|
||||
m_MoreOptionsParams.bOnlineSettingChangedBySystem=false;
|
||||
@@ -741,7 +753,10 @@ HRESULT CScene_LoadGameSettings::OnTimer( XUIMessageTimer *pTimer, BOOL& bHandle
|
||||
{
|
||||
case GAME_CREATE_ONLINE_TIMER_ID:
|
||||
{
|
||||
bool bMultiplayerAllowed = ProfileManager.IsSignedInLive( m_iPad ) && ProfileManager.AllowedToPlayMultiplayer(m_iPad);
|
||||
bool bMultiplayerAllowed = true;
|
||||
#ifndef _DISABLE_XBLIVE
|
||||
bMultiplayerAllowed = ProfileManager.IsSignedInLive( m_iPad ) && ProfileManager.AllowedToPlayMultiplayer(m_iPad);
|
||||
#endif
|
||||
|
||||
if(bMultiplayerAllowed != m_bMultiplayerAllowed)
|
||||
{
|
||||
@@ -1015,7 +1030,9 @@ int CScene_LoadGameSettings::StartGame_SignInReturned(void *pParam,bool bContinu
|
||||
{
|
||||
if(ProfileManager.IsSignedIn(index) )
|
||||
{
|
||||
#ifndef _DISABLE_XBLIVE
|
||||
if( !ProfileManager.AllowedToPlayMultiplayer(index) ) noPrivileges = true;
|
||||
#endif
|
||||
dwLocalUsersMask |= CGameNetworkManager::GetLocalPlayerMask(index);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -67,7 +67,19 @@ HRESULT CScene_MultiGameCreate::OnInit( XUIMessageInit* pInitData, BOOL& bHandle
|
||||
m_iPad=params->iPad;
|
||||
delete params;
|
||||
|
||||
#ifndef _DISABLE_XBLIVE
|
||||
#ifndef _DISABLE_XBLIVE
|
||||
#ifndef _DISABLE_XBLIVE
|
||||
m_bMultiplayerAllowed = ProfileManager.IsSignedInLive( m_iPad ) && ProfileManager.AllowedToPlayMultiplayer(m_iPad);
|
||||
#else
|
||||
m_bMultiplayerAllowed = true;
|
||||
#endif
|
||||
#else
|
||||
m_bMultiplayerAllowed = true;
|
||||
#endif
|
||||
#else
|
||||
m_bMultiplayerAllowed = true;
|
||||
#endif
|
||||
// 4J-PB - read the settings for the online flag. We'll only save this setting if the user changed it.
|
||||
bool bGameSetting_Online=(app.GetGameSettings(m_iPad,eGameSetting_Online)!=0);
|
||||
m_MoreOptionsParams.bOnlineSettingChangedBySystem=false;
|
||||
@@ -663,7 +675,10 @@ HRESULT CScene_MultiGameCreate::OnTimer( XUIMessageTimer *pTimer, BOOL& bHandled
|
||||
|
||||
case GAME_CREATE_ONLINE_TIMER_ID:
|
||||
{
|
||||
bool bMultiplayerAllowed = ProfileManager.IsSignedInLive( m_iPad ) && ProfileManager.AllowedToPlayMultiplayer(m_iPad);
|
||||
bool bMultiplayerAllowed = true;
|
||||
#ifndef _DISABLE_XBLIVE
|
||||
bMultiplayerAllowed = ProfileManager.IsSignedInLive( m_iPad ) && ProfileManager.AllowedToPlayMultiplayer(m_iPad);
|
||||
#endif
|
||||
|
||||
if(bMultiplayerAllowed != m_bMultiplayerAllowed)
|
||||
{
|
||||
@@ -824,7 +839,9 @@ int CScene_MultiGameCreate::StartGame_SignInReturned(void *pParam,bool bContinue
|
||||
{
|
||||
if(ProfileManager.IsSignedIn(index) )
|
||||
{
|
||||
#ifndef _DISABLE_XBLIVE
|
||||
if( !ProfileManager.AllowedToPlayMultiplayer(index) ) noPrivileges = true;
|
||||
#endif
|
||||
dwLocalUsersMask |= CGameNetworkManager::GetLocalPlayerMask(index);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -274,7 +274,9 @@ void CScene_MultiGameInfo::JoinGame(CScene_MultiGameInfo* pClass)
|
||||
if(ProfileManager.IsSignedIn(index) )
|
||||
{
|
||||
++dwSignedInUsers;
|
||||
#ifndef _DISABLE_XBLIVE
|
||||
if( !ProfileManager.AllowedToPlayMultiplayer(index) ) noPrivileges = true;
|
||||
#endif
|
||||
dwLocalUsersMask |= CGameNetworkManager::GetLocalPlayerMask(index);
|
||||
}
|
||||
}
|
||||
@@ -284,7 +286,9 @@ void CScene_MultiGameInfo::JoinGame(CScene_MultiGameInfo* pClass)
|
||||
if(ProfileManager.IsSignedIn(ProfileManager.GetPrimaryPad()) )
|
||||
{
|
||||
++dwSignedInUsers;
|
||||
#ifndef _DISABLE_XBLIVE
|
||||
if( !ProfileManager.AllowedToPlayMultiplayer(ProfileManager.GetPrimaryPad()) ) noPrivileges = true;
|
||||
#endif
|
||||
dwLocalUsersMask |= CGameNetworkManager::GetLocalPlayerMask(ProfileManager.GetPrimaryPad());
|
||||
}
|
||||
}
|
||||
@@ -348,6 +352,21 @@ void CScene_MultiGameInfo::JoinGame(CScene_MultiGameInfo* pClass)
|
||||
app.NavigateToHomeMenu();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
LoadingInputParams *loadingParams = new LoadingInputParams();
|
||||
loadingParams->func = &CGameNetworkManager::RunNetworkGameThreadProc;
|
||||
loadingParams->lpParam = NULL;
|
||||
|
||||
UIFullscreenProgressCompletionData *completionData = new UIFullscreenProgressCompletionData();
|
||||
completionData->bShowBackground = TRUE;
|
||||
completionData->bShowLogo = TRUE;
|
||||
completionData->type = e_ProgressCompletion_CloseAllPlayersUIScenes;
|
||||
completionData->iPad = DEFAULT_XUI_MENU_USER;
|
||||
loadingParams->completionData = completionData;
|
||||
|
||||
app.NavigateToScene(ProfileManager.GetPrimaryPad(), eUIScene_FullscreenProgress, loadingParams);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -73,7 +73,11 @@ HRESULT CScene_MultiGameJoinLoad::OnInit( XUIMessageInit* pInitData, BOOL& bHand
|
||||
// }
|
||||
|
||||
m_initData= new JoinMenuInitData();
|
||||
#ifndef _DISABLE_XBLIVE
|
||||
m_bMultiplayerAllowed = ProfileManager.IsSignedInLive( m_iPad ) && ProfileManager.AllowedToPlayMultiplayer(m_iPad);
|
||||
#else
|
||||
m_bMultiplayerAllowed = true;
|
||||
#endif
|
||||
|
||||
XPARTY_USER_LIST partyList;
|
||||
|
||||
@@ -768,7 +772,11 @@ HRESULT CScene_MultiGameJoinLoad::OnNavReturn(HXUIOBJ hSceneFrom,BOOL& rfHandled
|
||||
// start the texture pack timer again
|
||||
XuiSetTimer(m_hObj,CHECKFORAVAILABLETEXTUREPACKS_TIMER_ID,CHECKFORAVAILABLETEXTUREPACKS_TIMER_TIME);
|
||||
|
||||
m_bMultiplayerAllowed = ProfileManager.IsSignedInLive( m_iPad ) && ProfileManager.AllowedToPlayMultiplayer(m_iPad);
|
||||
#ifndef _DISABLE_XBLIVE
|
||||
m_bMultiplayerAllowed = ProfileManager.IsSignedInLive( m_iPad ) && ProfileManager.AllowedToPlayMultiplayer(m_iPad);
|
||||
#else
|
||||
m_bMultiplayerAllowed = true;
|
||||
#endif
|
||||
|
||||
// re-enable button presses
|
||||
m_bIgnoreInput=false;
|
||||
@@ -1643,7 +1651,10 @@ HRESULT CScene_MultiGameJoinLoad::OnTimer( XUIMessageTimer *pTimer, BOOL& bHandl
|
||||
m_bInParty=false;
|
||||
}
|
||||
|
||||
bool bMultiplayerAllowed = ProfileManager.IsSignedInLive( m_iPad ) && ProfileManager.AllowedToPlayMultiplayer(m_iPad);
|
||||
bool bMultiplayerAllowed = true;
|
||||
#ifndef _DISABLE_XBLIVE
|
||||
bMultiplayerAllowed = ProfileManager.IsSignedInLive( m_iPad ) && ProfileManager.AllowedToPlayMultiplayer(m_iPad);
|
||||
#endif
|
||||
if(bMultiplayerAllowed != m_bMultiplayerAllowed)
|
||||
{
|
||||
if( bMultiplayerAllowed )
|
||||
|
||||
Reference in New Issue
Block a user