mirror of
https://github.com/4jcraft/4jcraft.git
synced 2026-08-20 09:57:10 +00:00
format Platform/Common/Network
This commit is contained in:
parent
1c5311f058
commit
5f22cd8093
File diff suppressed because it is too large
Load diff
|
|
@ -1,5 +1,5 @@
|
||||||
#pragma once
|
#pragma once
|
||||||
//using namespace std;
|
// using namespace std;
|
||||||
#include <vector>
|
#include <vector>
|
||||||
#ifndef __linux__
|
#ifndef __linux__
|
||||||
#include <qnet.h>
|
#include <qnet.h>
|
||||||
|
|
@ -24,209 +24,235 @@
|
||||||
class ClientConnection;
|
class ClientConnection;
|
||||||
class Minecraft;
|
class Minecraft;
|
||||||
|
|
||||||
|
// This class implements the game-side interface to the networking system. As
|
||||||
|
// such, it is platform independent and may contain bits of game-side code where
|
||||||
|
// appropriate. It shouldn't ever reference any platform specifics of the
|
||||||
|
// network implementation (eg QNET), rather it should interface with an
|
||||||
|
// implementation of PlatformNetworkManager to provide this functionality.
|
||||||
|
|
||||||
// This class implements the game-side interface to the networking system. As such, it is platform independent and may contain bits of game-side code where appropriate.
|
class CGameNetworkManager {
|
||||||
// It shouldn't ever reference any platform specifics of the network implementation (eg QNET), rather it should interface with an implementation of PlatformNetworkManager to
|
|
||||||
// provide this functionality.
|
|
||||||
|
|
||||||
class CGameNetworkManager
|
|
||||||
{
|
|
||||||
#ifdef _XBOX
|
#ifdef _XBOX
|
||||||
friend class CPlatformNetworkManagerXbox;
|
friend class CPlatformNetworkManagerXbox;
|
||||||
#elif defined __PS3__ || defined __ORBIS__ || defined __PSVITA__
|
#elif defined __PS3__ || defined __ORBIS__ || defined __PSVITA__
|
||||||
friend class CPlatformNetworkManagerSony;
|
friend class CPlatformNetworkManagerSony;
|
||||||
#elif defined _DURANGO
|
#elif defined _DURANGO
|
||||||
friend class CPlatformNetworkManagerDurango;
|
friend class CPlatformNetworkManagerDurango;
|
||||||
#else
|
#else
|
||||||
friend class CPlatformNetworkManagerStub;
|
friend class CPlatformNetworkManagerStub;
|
||||||
#endif
|
#endif
|
||||||
public:
|
public:
|
||||||
CGameNetworkManager();
|
CGameNetworkManager();
|
||||||
// Misc high level flow
|
// Misc high level flow
|
||||||
|
|
||||||
typedef enum
|
typedef enum {
|
||||||
{
|
JOINGAME_SUCCESS,
|
||||||
JOINGAME_SUCCESS,
|
JOINGAME_FAIL_GENERAL,
|
||||||
JOINGAME_FAIL_GENERAL,
|
JOINGAME_FAIL_SERVER_FULL
|
||||||
JOINGAME_FAIL_SERVER_FULL
|
} eJoinGameResult;
|
||||||
} eJoinGameResult;
|
|
||||||
|
|
||||||
void Initialise();
|
void Initialise();
|
||||||
void Terminate();
|
void Terminate();
|
||||||
void DoWork();
|
void DoWork();
|
||||||
bool _RunNetworkGame(void *lpParameter);
|
bool _RunNetworkGame(void* lpParameter);
|
||||||
bool StartNetworkGame(Minecraft *minecraft, void *lpParameter);
|
bool StartNetworkGame(Minecraft* minecraft, void* lpParameter);
|
||||||
int CorrectErrorIDS(int IDS);
|
int CorrectErrorIDS(int IDS);
|
||||||
|
|
||||||
// Player management
|
// Player management
|
||||||
|
|
||||||
static int GetLocalPlayerMask(int playerIndex);
|
static int GetLocalPlayerMask(int playerIndex);
|
||||||
int GetPlayerCount();
|
int GetPlayerCount();
|
||||||
int GetOnlinePlayerCount();
|
int GetOnlinePlayerCount();
|
||||||
bool AddLocalPlayerByUserIndex( int userIndex );
|
bool AddLocalPlayerByUserIndex(int userIndex);
|
||||||
bool RemoveLocalPlayerByUserIndex( int userIndex );
|
bool RemoveLocalPlayerByUserIndex(int userIndex);
|
||||||
INetworkPlayer *GetLocalPlayerByUserIndex(int userIndex );
|
INetworkPlayer* GetLocalPlayerByUserIndex(int userIndex);
|
||||||
INetworkPlayer *GetPlayerByIndex(int playerIndex);
|
INetworkPlayer* GetPlayerByIndex(int playerIndex);
|
||||||
INetworkPlayer *GetPlayerByXuid(PlayerUID xuid);
|
INetworkPlayer* GetPlayerByXuid(PlayerUID xuid);
|
||||||
INetworkPlayer *GetPlayerBySmallId(unsigned char smallId);
|
INetworkPlayer* GetPlayerBySmallId(unsigned char smallId);
|
||||||
std::wstring GetDisplayNameByGamertag(std::wstring gamertag);
|
std::wstring GetDisplayNameByGamertag(std::wstring gamertag);
|
||||||
INetworkPlayer *GetHostPlayer();
|
INetworkPlayer* GetHostPlayer();
|
||||||
void RegisterPlayerChangedCallback(int iPad, void (*callback)(void *callbackParam, INetworkPlayer *pPlayer, bool leaving), void *callbackParam);
|
void RegisterPlayerChangedCallback(int iPad,
|
||||||
void UnRegisterPlayerChangedCallback(int iPad, void (*callback)(void *callbackParam, INetworkPlayer *pPlayer, bool leaving), void *callbackParam);
|
void (*callback)(void* callbackParam,
|
||||||
void HandleSignInChange();
|
INetworkPlayer* pPlayer,
|
||||||
bool ShouldMessageForFullSession();
|
bool leaving),
|
||||||
|
void* callbackParam);
|
||||||
|
void UnRegisterPlayerChangedCallback(
|
||||||
|
int iPad,
|
||||||
|
void (*callback)(void* callbackParam, INetworkPlayer* pPlayer,
|
||||||
|
bool leaving),
|
||||||
|
void* callbackParam);
|
||||||
|
void HandleSignInChange();
|
||||||
|
bool ShouldMessageForFullSession();
|
||||||
|
|
||||||
// State management
|
// State management
|
||||||
|
|
||||||
bool IsInSession();
|
bool IsInSession();
|
||||||
bool IsInGameplay();
|
bool IsInGameplay();
|
||||||
bool IsLeavingGame();
|
bool IsLeavingGame();
|
||||||
bool IsReadyToPlayOrIdle();
|
bool IsReadyToPlayOrIdle();
|
||||||
|
|
||||||
// Hosting and game type
|
// Hosting and game type
|
||||||
|
|
||||||
bool SetLocalGame(bool isLocal);
|
bool SetLocalGame(bool isLocal);
|
||||||
bool IsLocalGame();
|
bool IsLocalGame();
|
||||||
void SetPrivateGame(bool isPrivate);
|
void SetPrivateGame(bool isPrivate);
|
||||||
bool IsPrivateGame();
|
bool IsPrivateGame();
|
||||||
void HostGame(int localUsersMask, bool bOnlineGame, bool bIsPrivate, unsigned char publicSlots = MINECRAFT_NET_MAX_PLAYERS, unsigned char privateSlots = 0);
|
void HostGame(int localUsersMask, bool bOnlineGame, bool bIsPrivate,
|
||||||
bool IsHost();
|
unsigned char publicSlots = MINECRAFT_NET_MAX_PLAYERS,
|
||||||
bool IsInStatsEnabledSession();
|
unsigned char privateSlots = 0);
|
||||||
|
bool IsHost();
|
||||||
|
bool IsInStatsEnabledSession();
|
||||||
|
|
||||||
// Client session discovery
|
// Client session discovery
|
||||||
|
|
||||||
bool SessionHasSpace(unsigned int spaceRequired = 1);
|
bool SessionHasSpace(unsigned int spaceRequired = 1);
|
||||||
std::vector<FriendSessionInfo *> *GetSessionList(int iPad, int localPlayers, bool partyOnly);
|
std::vector<FriendSessionInfo*>* GetSessionList(int iPad, int localPlayers,
|
||||||
bool GetGameSessionInfo(int iPad, SessionID sessionId,FriendSessionInfo *foundSession);
|
bool partyOnly);
|
||||||
void SetSessionsUpdatedCallback( void (*SessionsUpdatedCallback)(void *pParam), void *pSearchParam );
|
bool GetGameSessionInfo(int iPad, SessionID sessionId,
|
||||||
void GetFullFriendSessionInfo( FriendSessionInfo *foundSession, void (* FriendSessionUpdatedFn)(bool success, void *pParam), void *pParam );
|
FriendSessionInfo* foundSession);
|
||||||
void ForceFriendsSessionRefresh();
|
void SetSessionsUpdatedCallback(
|
||||||
|
void (*SessionsUpdatedCallback)(void* pParam), void* pSearchParam);
|
||||||
// Session joining and leaving
|
void GetFullFriendSessionInfo(FriendSessionInfo* foundSession,
|
||||||
|
void (*FriendSessionUpdatedFn)(bool success,
|
||||||
|
void* pParam),
|
||||||
|
void* pParam);
|
||||||
|
void ForceFriendsSessionRefresh();
|
||||||
|
|
||||||
bool JoinGameFromInviteInfo( int userIndex, int userMask, const INVITE_INFO *pInviteInfo);
|
// Session joining and leaving
|
||||||
eJoinGameResult JoinGame(FriendSessionInfo *searchResult, int localUsersMask);
|
|
||||||
static void CancelJoinGame(void *lpParam); // Not part of the shared interface
|
|
||||||
bool LeaveGame(bool bMigrateHost);
|
|
||||||
static int JoinFromInvite_SignInReturned(void *pParam,bool bContinue, int iPad);
|
|
||||||
void UpdateAndSetGameSessionData(INetworkPlayer *pNetworkPlayerLeaving = NULL);
|
|
||||||
void SendInviteGUI(int iPad);
|
|
||||||
void ResetLeavingGame();
|
|
||||||
|
|
||||||
// Threads
|
bool JoinGameFromInviteInfo(int userIndex, int userMask,
|
||||||
|
const INVITE_INFO* pInviteInfo);
|
||||||
bool IsNetworkThreadRunning();
|
eJoinGameResult JoinGame(FriendSessionInfo* searchResult,
|
||||||
static int RunNetworkGameThreadProc( void* lpParameter );
|
int localUsersMask);
|
||||||
static int ServerThreadProc( void* lpParameter );
|
static void CancelJoinGame(
|
||||||
static int ExitAndJoinFromInviteThreadProc( void* lpParam );
|
void* lpParam); // Not part of the shared interface
|
||||||
|
bool LeaveGame(bool bMigrateHost);
|
||||||
|
static int JoinFromInvite_SignInReturned(void* pParam, bool bContinue,
|
||||||
|
int iPad);
|
||||||
|
void UpdateAndSetGameSessionData(
|
||||||
|
INetworkPlayer* pNetworkPlayerLeaving = NULL);
|
||||||
|
void SendInviteGUI(int iPad);
|
||||||
|
void ResetLeavingGame();
|
||||||
|
|
||||||
#if (defined __PS3__) || (defined __ORBIS__) || (defined __PSVITA__)
|
// Threads
|
||||||
static int MustSignInReturned_0(void *pParam,int iPad,C4JStorage::EMessageResult result);
|
|
||||||
static int PSNSignInReturned_0(void* pParam, bool bContinue, int iPad);
|
|
||||||
|
|
||||||
static int MustSignInReturned_1(void *pParam,int iPad,C4JStorage::EMessageResult result);
|
bool IsNetworkThreadRunning();
|
||||||
static int PSNSignInReturned_1(void* pParam, bool bContinue, int iPad);
|
static int RunNetworkGameThreadProc(void* lpParameter);
|
||||||
|
static int ServerThreadProc(void* lpParameter);
|
||||||
|
static int ExitAndJoinFromInviteThreadProc(void* lpParam);
|
||||||
|
|
||||||
|
#if (defined __PS3__) || (defined __ORBIS__) || (defined __PSVITA__)
|
||||||
|
static int MustSignInReturned_0(void* pParam, int iPad,
|
||||||
|
C4JStorage::EMessageResult result);
|
||||||
|
static int PSNSignInReturned_0(void* pParam, bool bContinue, int iPad);
|
||||||
|
|
||||||
|
static int MustSignInReturned_1(void* pParam, int iPad,
|
||||||
|
C4JStorage::EMessageResult result);
|
||||||
|
static int PSNSignInReturned_1(void* pParam, bool bContinue, int iPad);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
static void _LeaveGame();
|
static void _LeaveGame();
|
||||||
static int ChangeSessionTypeThreadProc( void* lpParam );
|
static int ChangeSessionTypeThreadProc(void* lpParam);
|
||||||
|
|
||||||
// System flags
|
// System flags
|
||||||
|
|
||||||
void SystemFlagSet(INetworkPlayer *pNetworkPlayer, int index);
|
void SystemFlagSet(INetworkPlayer* pNetworkPlayer, int index);
|
||||||
bool SystemFlagGet(INetworkPlayer *pNetworkPlayer, int index);
|
bool SystemFlagGet(INetworkPlayer* pNetworkPlayer, int index);
|
||||||
|
|
||||||
// Events
|
// Events
|
||||||
|
|
||||||
void ServerReadyCreate(bool create); // Create the signal (or set to NULL)
|
void ServerReadyCreate(bool create); // Create the signal (or set to NULL)
|
||||||
void ServerReady(); // Signal that we are ready
|
void ServerReady(); // Signal that we are ready
|
||||||
void ServerReadyWait(); // Wait for the signal
|
void ServerReadyWait(); // Wait for the signal
|
||||||
void ServerReadyDestroy(); // Destroy signal
|
void ServerReadyDestroy(); // Destroy signal
|
||||||
bool ServerReadyValid(); // Is non-NULL
|
bool ServerReadyValid(); // Is non-NULL
|
||||||
|
|
||||||
void ServerStoppedCreate(bool create); // Create the signal
|
void ServerStoppedCreate(bool create); // Create the signal
|
||||||
void ServerStopped(); // Signal that we are ready
|
void ServerStopped(); // Signal that we are ready
|
||||||
void ServerStoppedWait(); // Wait for the signal
|
void ServerStoppedWait(); // Wait for the signal
|
||||||
void ServerStoppedDestroy(); // Destroy signal
|
void ServerStoppedDestroy(); // Destroy signal
|
||||||
bool ServerStoppedValid(); // Is non-NULL
|
bool ServerStoppedValid(); // Is non-NULL
|
||||||
|
|
||||||
#ifdef __PSVITA__
|
#ifdef __PSVITA__
|
||||||
static bool usingAdhocMode();
|
static bool usingAdhocMode();
|
||||||
static void setAdhocMode(bool bAdhoc);
|
static void setAdhocMode(bool bAdhoc);
|
||||||
static void startAdhocMatching();
|
static void startAdhocMatching();
|
||||||
#endif
|
#endif
|
||||||
// Debug output
|
// Debug output
|
||||||
|
|
||||||
std::wstring GatherStats();
|
std::wstring GatherStats();
|
||||||
void renderQueueMeter();
|
void renderQueueMeter();
|
||||||
std::wstring GatherRTTStats();
|
std::wstring GatherRTTStats();
|
||||||
|
|
||||||
// GUI debug output
|
// GUI debug output
|
||||||
|
|
||||||
// Used for debugging output
|
// Used for debugging output
|
||||||
static const int messageQueue_length = 512;
|
static const int messageQueue_length = 512;
|
||||||
static __int64 messageQueue[messageQueue_length];
|
static __int64 messageQueue[messageQueue_length];
|
||||||
static const int byteQueue_length = 512;
|
static const int byteQueue_length = 512;
|
||||||
static __int64 byteQueue[byteQueue_length];
|
static __int64 byteQueue[byteQueue_length];
|
||||||
static int messageQueuePos;
|
static int messageQueuePos;
|
||||||
|
|
||||||
// Methods called from PlatformNetworkManager
|
// Methods called from PlatformNetworkManager
|
||||||
private:
|
private:
|
||||||
void StateChange_AnyToHosting();
|
void StateChange_AnyToHosting();
|
||||||
void StateChange_AnyToJoining();
|
void StateChange_AnyToJoining();
|
||||||
void StateChange_JoiningToIdle(CPlatformNetworkManager::eJoinFailedReason reason);
|
void StateChange_JoiningToIdle(
|
||||||
void StateChange_AnyToStarting();
|
CPlatformNetworkManager::eJoinFailedReason reason);
|
||||||
void StateChange_AnyToEnding(bool bStateWasPlaying);
|
void StateChange_AnyToStarting();
|
||||||
void StateChange_AnyToIdle();
|
void StateChange_AnyToEnding(bool bStateWasPlaying);
|
||||||
void CreateSocket( INetworkPlayer *pNetworkPlayer, bool localPlayer );
|
void StateChange_AnyToIdle();
|
||||||
void CloseConnection( INetworkPlayer *pNetworkPlayer );
|
void CreateSocket(INetworkPlayer* pNetworkPlayer, bool localPlayer);
|
||||||
void PlayerJoining( INetworkPlayer *pNetworkPlayer );
|
void CloseConnection(INetworkPlayer* pNetworkPlayer);
|
||||||
void PlayerLeaving( INetworkPlayer *pNetworkPlayer );
|
void PlayerJoining(INetworkPlayer* pNetworkPlayer);
|
||||||
void HostChanged();
|
void PlayerLeaving(INetworkPlayer* pNetworkPlayer);
|
||||||
void WriteStats( INetworkPlayer *pNetworkPlayer );
|
void HostChanged();
|
||||||
void GameInviteReceived( int userIndex, const INVITE_INFO *pInviteInfo);
|
void WriteStats(INetworkPlayer* pNetworkPlayer);
|
||||||
void HandleInviteWhenInMenus( int userIndex, const INVITE_INFO *pInviteInfo);
|
void GameInviteReceived(int userIndex, const INVITE_INFO* pInviteInfo);
|
||||||
void AddLocalPlayerFailed(int idx, bool serverFull = false);
|
void HandleInviteWhenInMenus(int userIndex, const INVITE_INFO* pInviteInfo);
|
||||||
|
void AddLocalPlayerFailed(int idx, bool serverFull = false);
|
||||||
#if defined __PS3__ || defined __PSVITA__ || defined __ORBIS__
|
#if defined __PS3__ || defined __PSVITA__ || defined __ORBIS__
|
||||||
void HandleDisconnect(bool bLostRoomOnly,bool bPSNSignOut);
|
void HandleDisconnect(bool bLostRoomOnly, bool bPSNSignOut);
|
||||||
#else
|
#else
|
||||||
void HandleDisconnect(bool bLostRoomOnly);
|
void HandleDisconnect(bool bLostRoomOnly);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
int GetPrimaryPad();
|
int GetPrimaryPad();
|
||||||
int GetLockedProfile();
|
int GetLockedProfile();
|
||||||
bool IsSignedInLive(int playerIdx);
|
bool IsSignedInLive(int playerIdx);
|
||||||
bool AllowedToPlayMultiplayer(int playerIdx);
|
bool AllowedToPlayMultiplayer(int playerIdx);
|
||||||
char *GetOnlineName(int playerIdx);
|
char* GetOnlineName(int playerIdx);
|
||||||
|
|
||||||
C4JThread::Event* m_hServerStoppedEvent;
|
C4JThread::Event* m_hServerStoppedEvent;
|
||||||
C4JThread::Event* m_hServerReadyEvent;
|
C4JThread::Event* m_hServerReadyEvent;
|
||||||
bool m_bInitialised;
|
bool m_bInitialised;
|
||||||
|
|
||||||
#ifdef _XBOX_ONE
|
#ifdef _XBOX_ONE
|
||||||
public:
|
public:
|
||||||
void SetFullSessionMessageOnNextSessionChange() { m_bFullSessionMessageOnNextSessionChange = true; }
|
void SetFullSessionMessageOnNextSessionChange() {
|
||||||
|
m_bFullSessionMessageOnNextSessionChange = true;
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
private:
|
private:
|
||||||
float m_lastPlayerEventTimeStart; // For telemetry
|
float m_lastPlayerEventTimeStart; // For telemetry
|
||||||
static CPlatformNetworkManager *s_pPlatformNetworkManager;
|
static CPlatformNetworkManager* s_pPlatformNetworkManager;
|
||||||
bool m_bNetworkThreadRunning;
|
bool m_bNetworkThreadRunning;
|
||||||
int GetJoiningReadyPercentage();
|
int GetJoiningReadyPercentage();
|
||||||
bool m_bLastDisconnectWasLostRoomOnly;
|
bool m_bLastDisconnectWasLostRoomOnly;
|
||||||
bool m_bFullSessionMessageOnNextSessionChange;
|
bool m_bFullSessionMessageOnNextSessionChange;
|
||||||
#if defined __PS3__ || defined __PSVITA__ || defined __ORBIS__
|
#if defined __PS3__ || defined __PSVITA__ || defined __ORBIS__
|
||||||
bool m_bSignedOutofPSN;
|
bool m_bSignedOutofPSN;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef __ORBIS__
|
#ifdef __ORBIS__
|
||||||
PsPlusUpsellWrapper *m_pUpsell;
|
PsPlusUpsellWrapper* m_pUpsell;
|
||||||
INVITE_INFO *m_pInviteInfo;
|
INVITE_INFO* m_pInviteInfo;
|
||||||
int m_iPlayerInvited;
|
int m_iPlayerInvited;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
public:
|
public:
|
||||||
#ifndef _XBOX
|
#ifndef _XBOX
|
||||||
void FakeLocalPlayerJoined(); // Temporary method whilst we don't have real networking to make this happen
|
void FakeLocalPlayerJoined(); // Temporary method whilst we don't have real
|
||||||
|
// networking to make this happen
|
||||||
#endif
|
#endif
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -2,30 +2,34 @@
|
||||||
|
|
||||||
class Socket;
|
class Socket;
|
||||||
|
|
||||||
// This is the platform independent interface for dealing with players within a network game. This should be used directly by game code (and GameNetworkManager) rather than the platform-specific implementations.
|
// This is the platform independent interface for dealing with players within a
|
||||||
|
// network game. This should be used directly by game code (and
|
||||||
|
// GameNetworkManager) rather than the platform-specific implementations.
|
||||||
|
|
||||||
class INetworkPlayer
|
class INetworkPlayer {
|
||||||
{
|
|
||||||
public:
|
public:
|
||||||
virtual ~INetworkPlayer() {}
|
virtual ~INetworkPlayer() {}
|
||||||
virtual unsigned char GetSmallId() = 0;
|
virtual unsigned char GetSmallId() = 0;
|
||||||
virtual void SendData(INetworkPlayer *player, const void *pvData, int dataSize, bool lowPriority) = 0;
|
virtual void SendData(INetworkPlayer* player, const void* pvData,
|
||||||
virtual bool IsSameSystem(INetworkPlayer *player) = 0;
|
int dataSize, bool lowPriority) = 0;
|
||||||
virtual int GetSendQueueSizeBytes( INetworkPlayer *player, bool lowPriority ) = 0;
|
virtual bool IsSameSystem(INetworkPlayer* player) = 0;
|
||||||
virtual int GetSendQueueSizeMessages( INetworkPlayer *player, bool lowPriority ) = 0;
|
virtual int GetSendQueueSizeBytes(INetworkPlayer* player,
|
||||||
virtual int GetCurrentRtt() = 0;
|
bool lowPriority) = 0;
|
||||||
virtual bool IsHost() = 0;
|
virtual int GetSendQueueSizeMessages(INetworkPlayer* player,
|
||||||
virtual bool IsGuest() = 0;
|
bool lowPriority) = 0;
|
||||||
virtual bool IsLocal() = 0;
|
virtual int GetCurrentRtt() = 0;
|
||||||
virtual int GetSessionIndex() = 0;
|
virtual bool IsHost() = 0;
|
||||||
virtual bool IsTalking() = 0;
|
virtual bool IsGuest() = 0;
|
||||||
virtual bool IsMutedByLocalUser(int userIndex) = 0;
|
virtual bool IsLocal() = 0;
|
||||||
virtual bool HasVoice() = 0;
|
virtual int GetSessionIndex() = 0;
|
||||||
virtual bool HasCamera() = 0;
|
virtual bool IsTalking() = 0;
|
||||||
virtual int GetUserIndex() = 0;
|
virtual bool IsMutedByLocalUser(int userIndex) = 0;
|
||||||
virtual void SetSocket(Socket *pSocket) = 0;
|
virtual bool HasVoice() = 0;
|
||||||
virtual Socket *GetSocket() = 0;
|
virtual bool HasCamera() = 0;
|
||||||
virtual const wchar_t *GetOnlineName() = 0;
|
virtual int GetUserIndex() = 0;
|
||||||
virtual std::wstring GetDisplayName() = 0;
|
virtual void SetSocket(Socket* pSocket) = 0;
|
||||||
virtual PlayerUID GetUID() = 0;
|
virtual Socket* GetSocket() = 0;
|
||||||
|
virtual const wchar_t* GetOnlineName() = 0;
|
||||||
|
virtual std::wstring GetDisplayName() = 0;
|
||||||
|
virtual PlayerUID GetUID() = 0;
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -1,9 +1,9 @@
|
||||||
#pragma once
|
#pragma once
|
||||||
//using namespace std;
|
// using namespace std;
|
||||||
#include <vector>
|
#include <vector>
|
||||||
#ifndef __linux__
|
#ifndef __linux__
|
||||||
#include <qnet.h>
|
#include <qnet.h>
|
||||||
#endif // __linux__
|
#endif // __linux__
|
||||||
#include "../../Minecraft.World/Util/C4JThread.h"
|
#include "../../Minecraft.World/Util/C4JThread.h"
|
||||||
#include "NetworkPlayerInterface.h"
|
#include "NetworkPlayerInterface.h"
|
||||||
#include "SessionInfo.h"
|
#include "SessionInfo.h"
|
||||||
|
|
@ -12,117 +12,139 @@ class ClientConnection;
|
||||||
class Minecraft;
|
class Minecraft;
|
||||||
class CGameNetworkManager;
|
class CGameNetworkManager;
|
||||||
|
|
||||||
// This is the interface to be implemented by the platform-specific versions of the PlatformNetworkManagers. This API is used directly by GameNetworkManager so that
|
// This is the interface to be implemented by the platform-specific versions of
|
||||||
// it can remain as platform independent as possible.
|
// the PlatformNetworkManagers. This API is used directly by GameNetworkManager
|
||||||
|
// so that it can remain as platform independent as possible.
|
||||||
|
|
||||||
// This value should be incremented if the server version changes, or the game session data changes
|
// This value should be incremented if the server version changes, or the game
|
||||||
|
// session data changes
|
||||||
#define MINECRAFT_NET_VERSION VER_NETWORK
|
#define MINECRAFT_NET_VERSION VER_NETWORK
|
||||||
|
|
||||||
|
typedef struct _SearchForGamesData {
|
||||||
typedef struct _SearchForGamesData
|
unsigned int sessionIDCount;
|
||||||
{
|
XSESSION_SEARCHRESULT_HEADER* searchBuffer;
|
||||||
unsigned int sessionIDCount;
|
XNQOS** ppQos;
|
||||||
XSESSION_SEARCHRESULT_HEADER *searchBuffer;
|
SessionID* sessionIDList;
|
||||||
XNQOS **ppQos;
|
XOVERLAPPED* pOverlapped;
|
||||||
SessionID *sessionIDList;
|
|
||||||
XOVERLAPPED *pOverlapped;
|
|
||||||
} SearchForGamesData;
|
} SearchForGamesData;
|
||||||
|
|
||||||
class CPlatformNetworkManager
|
class CPlatformNetworkManager {
|
||||||
{
|
friend class CGameNetworkManager;
|
||||||
friend class CGameNetworkManager;
|
|
||||||
public:
|
public:
|
||||||
|
typedef enum {
|
||||||
|
JOIN_FAILED_SERVER_FULL,
|
||||||
|
JOIN_FAILED_INSUFFICIENT_PRIVILEGES,
|
||||||
|
JOIN_FAILED_NONSPECIFIC,
|
||||||
|
} eJoinFailedReason;
|
||||||
|
|
||||||
typedef enum
|
virtual bool Initialise(CGameNetworkManager* pGameNetworkManager,
|
||||||
{
|
int flagIndexSize) = 0;
|
||||||
JOIN_FAILED_SERVER_FULL,
|
virtual void Terminate() = 0;
|
||||||
JOIN_FAILED_INSUFFICIENT_PRIVILEGES,
|
virtual int GetJoiningReadyPercentage() = 0;
|
||||||
JOIN_FAILED_NONSPECIFIC,
|
virtual int CorrectErrorIDS(int IDS) = 0;
|
||||||
} eJoinFailedReason;
|
|
||||||
|
|
||||||
virtual bool Initialise(CGameNetworkManager *pGameNetworkManager, int flagIndexSize) = 0;
|
virtual void DoWork() = 0;
|
||||||
virtual void Terminate() = 0;
|
virtual int GetPlayerCount() = 0;
|
||||||
virtual int GetJoiningReadyPercentage() = 0;
|
virtual int GetOnlinePlayerCount() = 0;
|
||||||
virtual int CorrectErrorIDS(int IDS) = 0;
|
virtual int GetLocalPlayerMask(int playerIndex) = 0;
|
||||||
|
virtual bool AddLocalPlayerByUserIndex(int userIndex) = 0;
|
||||||
|
virtual bool RemoveLocalPlayerByUserIndex(int userIndex) = 0;
|
||||||
|
virtual INetworkPlayer* GetLocalPlayerByUserIndex(int userIndex) = 0;
|
||||||
|
virtual INetworkPlayer* GetPlayerByIndex(int playerIndex) = 0;
|
||||||
|
virtual INetworkPlayer* GetPlayerByXuid(PlayerUID xuid) = 0;
|
||||||
|
virtual INetworkPlayer* GetPlayerBySmallId(unsigned char smallId) = 0;
|
||||||
|
virtual bool ShouldMessageForFullSession() = 0;
|
||||||
|
|
||||||
virtual void DoWork() = 0;
|
virtual INetworkPlayer* GetHostPlayer() = 0;
|
||||||
virtual int GetPlayerCount() = 0;
|
virtual bool IsHost() = 0;
|
||||||
virtual int GetOnlinePlayerCount() = 0;
|
virtual bool JoinGameFromInviteInfo(int userIndex, int userMask,
|
||||||
virtual int GetLocalPlayerMask(int playerIndex) = 0;
|
const INVITE_INFO* pInviteInfo) = 0;
|
||||||
virtual bool AddLocalPlayerByUserIndex( int userIndex ) = 0;
|
virtual bool LeaveGame(bool bMigrateHost) = 0;
|
||||||
virtual bool RemoveLocalPlayerByUserIndex( int userIndex ) = 0;
|
|
||||||
virtual INetworkPlayer *GetLocalPlayerByUserIndex( int userIndex ) = 0;
|
|
||||||
virtual INetworkPlayer *GetPlayerByIndex(int playerIndex) = 0;
|
|
||||||
virtual INetworkPlayer * GetPlayerByXuid(PlayerUID xuid) = 0;
|
|
||||||
virtual INetworkPlayer * GetPlayerBySmallId(unsigned char smallId) = 0;
|
|
||||||
virtual bool ShouldMessageForFullSession() = 0;
|
|
||||||
|
|
||||||
virtual INetworkPlayer *GetHostPlayer() = 0;
|
virtual bool IsInSession() = 0;
|
||||||
virtual bool IsHost() = 0;
|
virtual bool IsInGameplay() = 0;
|
||||||
virtual bool JoinGameFromInviteInfo( int userIndex, int userMask, const INVITE_INFO *pInviteInfo) = 0;
|
virtual bool IsReadyToPlayOrIdle() = 0;
|
||||||
virtual bool LeaveGame(bool bMigrateHost) = 0;
|
virtual bool IsInStatsEnabledSession() = 0;
|
||||||
|
virtual bool SessionHasSpace(unsigned int spaceRequired = 1) = 0;
|
||||||
|
virtual void SendInviteGUI(int quadrant) = 0;
|
||||||
|
virtual bool IsAddingPlayer() = 0;
|
||||||
|
|
||||||
virtual bool IsInSession() = 0;
|
virtual void HostGame(int localUsersMask, bool bOnlineGame, bool bIsPrivate,
|
||||||
virtual bool IsInGameplay() = 0;
|
unsigned char publicSlots = MINECRAFT_NET_MAX_PLAYERS,
|
||||||
virtual bool IsReadyToPlayOrIdle() = 0;
|
unsigned char privateSlots = 0) = 0;
|
||||||
virtual bool IsInStatsEnabledSession() = 0;
|
virtual int JoinGame(FriendSessionInfo* searchResult, int dwLocalUsersMask,
|
||||||
virtual bool SessionHasSpace(unsigned int spaceRequired = 1) = 0;
|
int dwPrimaryUserIndex) = 0;
|
||||||
virtual void SendInviteGUI(int quadrant) = 0;
|
virtual void CancelJoinGame() {};
|
||||||
virtual bool IsAddingPlayer() = 0;
|
virtual bool SetLocalGame(bool isLocal) = 0;
|
||||||
|
virtual bool IsLocalGame() = 0;
|
||||||
|
virtual void SetPrivateGame(bool isPrivate) = 0;
|
||||||
|
virtual bool IsPrivateGame() = 0;
|
||||||
|
virtual bool IsLeavingGame() = 0;
|
||||||
|
virtual void ResetLeavingGame() = 0;
|
||||||
|
|
||||||
virtual void HostGame(int localUsersMask, bool bOnlineGame, bool bIsPrivate, unsigned char publicSlots = MINECRAFT_NET_MAX_PLAYERS, unsigned char privateSlots = 0) = 0;
|
virtual void RegisterPlayerChangedCallback(
|
||||||
virtual int JoinGame(FriendSessionInfo *searchResult, int dwLocalUsersMask, int dwPrimaryUserIndex ) = 0;
|
int iPad,
|
||||||
virtual void CancelJoinGame() {};
|
void (*callback)(void* callbackParam, INetworkPlayer* pPlayer,
|
||||||
virtual bool SetLocalGame(bool isLocal) = 0;
|
bool leaving),
|
||||||
virtual bool IsLocalGame() = 0;
|
void* callbackParam) = 0;
|
||||||
virtual void SetPrivateGame(bool isPrivate) = 0;
|
virtual void UnRegisterPlayerChangedCallback(
|
||||||
virtual bool IsPrivateGame() = 0;
|
int iPad,
|
||||||
virtual bool IsLeavingGame() = 0;
|
void (*callback)(void* callbackParam, INetworkPlayer* pPlayer,
|
||||||
virtual void ResetLeavingGame() = 0;
|
bool leaving),
|
||||||
|
void* callbackParam) = 0;
|
||||||
|
|
||||||
virtual void RegisterPlayerChangedCallback(int iPad, void (*callback)(void *callbackParam, INetworkPlayer *pPlayer, bool leaving), void *callbackParam) = 0;
|
virtual void HandleSignInChange() = 0;
|
||||||
virtual void UnRegisterPlayerChangedCallback(int iPad, void (*callback)(void *callbackParam, INetworkPlayer *pPlayer, bool leaving), void *callbackParam) = 0;
|
|
||||||
|
|
||||||
virtual void HandleSignInChange() = 0;
|
virtual bool _RunNetworkGame() = 0;
|
||||||
|
|
||||||
virtual bool _RunNetworkGame() = 0;
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
virtual bool _LeaveGame(bool bMigrateHost, bool bLeaveRoom) = 0;
|
virtual bool _LeaveGame(bool bMigrateHost, bool bLeaveRoom) = 0;
|
||||||
virtual void _HostGame(int usersMask, unsigned char publicSlots = MINECRAFT_NET_MAX_PLAYERS, unsigned char privateSlots = 0) = 0;
|
virtual void _HostGame(
|
||||||
virtual bool _StartGame() = 0;
|
int usersMask, unsigned char publicSlots = MINECRAFT_NET_MAX_PLAYERS,
|
||||||
|
unsigned char privateSlots = 0) = 0;
|
||||||
|
virtual bool _StartGame() = 0;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
virtual void UpdateAndSetGameSessionData(INetworkPlayer *pNetworkPlayerLeaving = NULL) = 0;
|
virtual void UpdateAndSetGameSessionData(
|
||||||
|
INetworkPlayer* pNetworkPlayerLeaving = NULL) = 0;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
virtual bool RemoveLocalPlayer( INetworkPlayer *pNetworkPlayer ) = 0;
|
virtual bool RemoveLocalPlayer(INetworkPlayer* pNetworkPlayer) = 0;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
virtual void SystemFlagSet(INetworkPlayer *pNetworkPlayer, int index) = 0;
|
virtual void SystemFlagSet(INetworkPlayer* pNetworkPlayer, int index) = 0;
|
||||||
virtual bool SystemFlagGet(INetworkPlayer *pNetworkPlayer, int index) = 0;
|
virtual bool SystemFlagGet(INetworkPlayer* pNetworkPlayer, int index) = 0;
|
||||||
|
|
||||||
virtual std::wstring GatherStats() = 0;
|
virtual std::wstring GatherStats() = 0;
|
||||||
virtual std::wstring GatherRTTStats() = 0;
|
virtual std::wstring GatherRTTStats() = 0;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
virtual void SetSessionTexturePackParentId( int id ) = 0;
|
virtual void SetSessionTexturePackParentId(int id) = 0;
|
||||||
virtual void SetSessionSubTexturePackId( int id ) = 0;
|
virtual void SetSessionSubTexturePackId(int id) = 0;
|
||||||
virtual void Notify(int ID, ULONG_PTR Param) = 0;
|
virtual void Notify(int ID, ULONG_PTR Param) = 0;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
virtual std::vector<FriendSessionInfo *> *GetSessionList(int iPad, int localPlayers, bool partyOnly) = 0;
|
virtual std::vector<FriendSessionInfo*>* GetSessionList(int iPad,
|
||||||
virtual bool GetGameSessionInfo(int iPad, SessionID sessionId,FriendSessionInfo *foundSession) = 0;
|
int localPlayers,
|
||||||
virtual void SetSessionsUpdatedCallback( void (*SessionsUpdatedCallback)(void *pParam), void *pSearchParam ) = 0;
|
bool partyOnly) = 0;
|
||||||
virtual void GetFullFriendSessionInfo( FriendSessionInfo *foundSession, void (* FriendSessionUpdatedFn)(bool success, void *pParam), void *pParam ) = 0;
|
virtual bool GetGameSessionInfo(int iPad, SessionID sessionId,
|
||||||
virtual void ForceFriendsSessionRefresh() = 0;
|
FriendSessionInfo* foundSession) = 0;
|
||||||
|
virtual void SetSessionsUpdatedCallback(
|
||||||
|
void (*SessionsUpdatedCallback)(void* pParam), void* pSearchParam) = 0;
|
||||||
|
virtual void GetFullFriendSessionInfo(
|
||||||
|
FriendSessionInfo* foundSession,
|
||||||
|
void (*FriendSessionUpdatedFn)(bool success, void* pParam),
|
||||||
|
void* pParam) = 0;
|
||||||
|
virtual void ForceFriendsSessionRefresh() = 0;
|
||||||
|
|
||||||
#ifndef _XBOX
|
#ifndef _XBOX
|
||||||
virtual void FakeLocalPlayerJoined() {}; // Temporary method whilst we don't have real networking to make this happen
|
virtual void FakeLocalPlayerJoined() {
|
||||||
|
}; // Temporary method whilst we don't have real networking to make this
|
||||||
|
// happen
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef _DURANGO
|
#ifdef _DURANGO
|
||||||
virtual std::wstring GetDisplayNameByGamertag(std::wstring gamertag) = 0;
|
virtual std::wstring GetDisplayNameByGamertag(std::wstring gamertag) = 0;
|
||||||
#endif
|
#endif
|
||||||
};
|
};
|
||||||
|
|
|
||||||
File diff suppressed because it is too large
Load diff
|
|
@ -1,170 +1,201 @@
|
||||||
#pragma once
|
#pragma once
|
||||||
//using namespace std;
|
// using namespace std;
|
||||||
#include <vector>
|
#include <vector>
|
||||||
#include "../../Minecraft.World/Util/C4JThread.h"
|
#include "../../Minecraft.World/Util/C4JThread.h"
|
||||||
#include "NetworkPlayerInterface.h"
|
#include "NetworkPlayerInterface.h"
|
||||||
#include "PlatformNetworkManagerInterface.h"
|
#include "PlatformNetworkManagerInterface.h"
|
||||||
#include "SessionInfo.h"
|
#include "SessionInfo.h"
|
||||||
|
|
||||||
class CPlatformNetworkManagerStub : public CPlatformNetworkManager
|
class CPlatformNetworkManagerStub : public CPlatformNetworkManager {
|
||||||
{
|
friend class CGameNetworkManager;
|
||||||
friend class CGameNetworkManager;
|
|
||||||
public:
|
public:
|
||||||
virtual bool Initialise(CGameNetworkManager *pGameNetworkManager, int flagIndexSize);
|
virtual bool Initialise(CGameNetworkManager* pGameNetworkManager,
|
||||||
virtual void Terminate();
|
int flagIndexSize);
|
||||||
virtual int GetJoiningReadyPercentage();
|
virtual void Terminate();
|
||||||
virtual int CorrectErrorIDS(int IDS);
|
virtual int GetJoiningReadyPercentage();
|
||||||
|
virtual int CorrectErrorIDS(int IDS);
|
||||||
|
|
||||||
virtual void DoWork();
|
virtual void DoWork();
|
||||||
virtual int GetPlayerCount();
|
virtual int GetPlayerCount();
|
||||||
virtual int GetOnlinePlayerCount();
|
virtual int GetOnlinePlayerCount();
|
||||||
virtual int GetLocalPlayerMask(int playerIndex);
|
virtual int GetLocalPlayerMask(int playerIndex);
|
||||||
virtual bool AddLocalPlayerByUserIndex( int userIndex );
|
virtual bool AddLocalPlayerByUserIndex(int userIndex);
|
||||||
virtual bool RemoveLocalPlayerByUserIndex( int userIndex );
|
virtual bool RemoveLocalPlayerByUserIndex(int userIndex);
|
||||||
virtual INetworkPlayer *GetLocalPlayerByUserIndex( int userIndex );
|
virtual INetworkPlayer* GetLocalPlayerByUserIndex(int userIndex);
|
||||||
virtual INetworkPlayer *GetPlayerByIndex(int playerIndex);
|
virtual INetworkPlayer* GetPlayerByIndex(int playerIndex);
|
||||||
virtual INetworkPlayer * GetPlayerByXuid(PlayerUID xuid);
|
virtual INetworkPlayer* GetPlayerByXuid(PlayerUID xuid);
|
||||||
virtual INetworkPlayer * GetPlayerBySmallId(unsigned char smallId);
|
virtual INetworkPlayer* GetPlayerBySmallId(unsigned char smallId);
|
||||||
virtual bool ShouldMessageForFullSession();
|
virtual bool ShouldMessageForFullSession();
|
||||||
|
|
||||||
virtual INetworkPlayer *GetHostPlayer();
|
virtual INetworkPlayer* GetHostPlayer();
|
||||||
virtual bool IsHost();
|
virtual bool IsHost();
|
||||||
virtual bool JoinGameFromInviteInfo( int userIndex, int userMask, const INVITE_INFO *pInviteInfo);
|
virtual bool JoinGameFromInviteInfo(int userIndex, int userMask,
|
||||||
virtual bool LeaveGame(bool bMigrateHost);
|
const INVITE_INFO* pInviteInfo);
|
||||||
|
virtual bool LeaveGame(bool bMigrateHost);
|
||||||
|
|
||||||
virtual bool IsInSession();
|
virtual bool IsInSession();
|
||||||
virtual bool IsInGameplay();
|
virtual bool IsInGameplay();
|
||||||
virtual bool IsReadyToPlayOrIdle();
|
virtual bool IsReadyToPlayOrIdle();
|
||||||
virtual bool IsInStatsEnabledSession();
|
virtual bool IsInStatsEnabledSession();
|
||||||
virtual bool SessionHasSpace(unsigned int spaceRequired = 1);
|
virtual bool SessionHasSpace(unsigned int spaceRequired = 1);
|
||||||
virtual void SendInviteGUI(int quadrant);
|
virtual void SendInviteGUI(int quadrant);
|
||||||
virtual bool IsAddingPlayer();
|
virtual bool IsAddingPlayer();
|
||||||
|
|
||||||
virtual void HostGame(int localUsersMask, bool bOnlineGame, bool bIsPrivate, unsigned char publicSlots = MINECRAFT_NET_MAX_PLAYERS, unsigned char privateSlots = 0);
|
virtual void HostGame(int localUsersMask, bool bOnlineGame, bool bIsPrivate,
|
||||||
virtual int JoinGame(FriendSessionInfo *searchResult, int localUsersMask, int primaryUserIndex );
|
unsigned char publicSlots = MINECRAFT_NET_MAX_PLAYERS,
|
||||||
virtual bool SetLocalGame(bool isLocal);
|
unsigned char privateSlots = 0);
|
||||||
virtual bool IsLocalGame() { return m_bIsOfflineGame; }
|
virtual int JoinGame(FriendSessionInfo* searchResult, int localUsersMask,
|
||||||
virtual void SetPrivateGame(bool isPrivate);
|
int primaryUserIndex);
|
||||||
virtual bool IsPrivateGame() { return m_bIsPrivateGame; }
|
virtual bool SetLocalGame(bool isLocal);
|
||||||
virtual bool IsLeavingGame() { return m_bLeavingGame; }
|
virtual bool IsLocalGame() { return m_bIsOfflineGame; }
|
||||||
virtual void ResetLeavingGame() { m_bLeavingGame = false; }
|
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 RegisterPlayerChangedCallback(
|
||||||
virtual void UnRegisterPlayerChangedCallback(int iPad, void (*callback)(void *callbackParam, INetworkPlayer *pPlayer, bool leaving), void *callbackParam);
|
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 void HandleSignInChange();
|
||||||
|
|
||||||
virtual bool _RunNetworkGame();
|
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;
|
|
||||||
|
|
||||||
std::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:
|
private:
|
||||||
// TODO 4J Stu - Do we need to be able to have more than one of these?
|
bool isSystemPrimaryPlayer(IQNetPlayer* pQNetPlayer);
|
||||||
void (*playerChangedCallback[XUSER_MAX_COUNT])(void *callbackParam, INetworkPlayer *pPlayer, bool leaving);
|
virtual bool _LeaveGame(bool bMigrateHost, bool bLeaveRoom);
|
||||||
void *playerChangedCallbackParam[XUSER_MAX_COUNT];
|
virtual void _HostGame(
|
||||||
|
int dwUsersMask, unsigned char publicSlots = MINECRAFT_NET_MAX_PLAYERS,
|
||||||
|
unsigned char privateSlots = 0);
|
||||||
|
virtual bool _StartGame();
|
||||||
|
|
||||||
static int RemovePlayerOnSocketClosedThreadProc( void* lpParam );
|
IQNet* m_pIQNet; // pointer to QNet interface
|
||||||
virtual bool RemoveLocalPlayer( INetworkPlayer *pNetworkPlayer );
|
|
||||||
|
|
||||||
// Things for handling per-system flags
|
HANDLE m_notificationListener;
|
||||||
class PlayerFlags
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
INetworkPlayer *m_pNetworkPlayer;
|
|
||||||
unsigned char *flags;
|
|
||||||
unsigned int count;
|
|
||||||
PlayerFlags(INetworkPlayer *pNetworkPlayer, unsigned int count);
|
|
||||||
~PlayerFlags();
|
|
||||||
};
|
|
||||||
std::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
|
std::vector<IQNetPlayer*>
|
||||||
private:
|
m_machineQNetPrimaryPlayers; // collection of players that we deem to
|
||||||
float m_lastPlayerEventTimeStart;
|
// 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:
|
public:
|
||||||
std::wstring GatherStats();
|
virtual void UpdateAndSetGameSessionData(
|
||||||
std::wstring GatherRTTStats();
|
INetworkPlayer* pNetworkPlayerLeaving = NULL);
|
||||||
|
|
||||||
private:
|
|
||||||
std::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;
|
|
||||||
void *m_pSearchParam;
|
|
||||||
void (*m_SessionsUpdatedCallback)(void *pParam);
|
|
||||||
|
|
||||||
C4JThread* m_SearchingThread;
|
|
||||||
|
|
||||||
void TickSearch();
|
|
||||||
void SearchForGames();
|
|
||||||
static int SearchForGamesThreadProc( void* lpParameter );
|
|
||||||
|
|
||||||
void SetSearchResultsReady(int resultCount = 0);
|
|
||||||
|
|
||||||
std::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 std::vector<FriendSessionInfo *> *GetSessionList(int iPad, int localPlayers, bool partyOnly);
|
|
||||||
virtual bool GetGameSessionInfo(int iPad, SessionID sessionId,FriendSessionInfo *foundSession);
|
|
||||||
virtual void SetSessionsUpdatedCallback( void (*SessionsUpdatedCallback)(void *pParam), void *pSearchParam );
|
|
||||||
virtual void GetFullFriendSessionInfo( FriendSessionInfo *foundSession, void (* FriendSessionUpdatedFn)(bool success, void *pParam), void *pParam );
|
|
||||||
virtual void ForceFriendsSessionRefresh();
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void NotifyPlayerJoined( IQNetPlayer *pQNetPlayer );
|
// 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();
|
||||||
|
};
|
||||||
|
std::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:
|
||||||
|
std::wstring GatherStats();
|
||||||
|
std::wstring GatherRTTStats();
|
||||||
|
|
||||||
|
private:
|
||||||
|
std::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;
|
||||||
|
void* m_pSearchParam;
|
||||||
|
void (*m_SessionsUpdatedCallback)(void* pParam);
|
||||||
|
|
||||||
|
C4JThread* m_SearchingThread;
|
||||||
|
|
||||||
|
void TickSearch();
|
||||||
|
void SearchForGames();
|
||||||
|
static int SearchForGamesThreadProc(void* lpParameter);
|
||||||
|
|
||||||
|
void SetSearchResultsReady(int resultCount = 0);
|
||||||
|
|
||||||
|
std::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 std::vector<FriendSessionInfo*>* GetSessionList(int iPad,
|
||||||
|
int localPlayers,
|
||||||
|
bool partyOnly);
|
||||||
|
virtual bool GetGameSessionInfo(int iPad, SessionID sessionId,
|
||||||
|
FriendSessionInfo* foundSession);
|
||||||
|
virtual void SetSessionsUpdatedCallback(
|
||||||
|
void (*SessionsUpdatedCallback)(void* pParam), void* pSearchParam);
|
||||||
|
virtual void GetFullFriendSessionInfo(
|
||||||
|
FriendSessionInfo* foundSession,
|
||||||
|
void (*FriendSessionUpdatedFn)(bool success, void* pParam),
|
||||||
|
void* pParam);
|
||||||
|
virtual void ForceFriendsSessionRefresh();
|
||||||
|
|
||||||
|
private:
|
||||||
|
void NotifyPlayerJoined(IQNetPlayer* pQNetPlayer);
|
||||||
|
|
||||||
#ifndef _XBOX
|
#ifndef _XBOX
|
||||||
void FakeLocalPlayerJoined() { NotifyPlayerJoined(m_pIQNet->GetLocalPlayerByUserIndex(0)); }
|
void FakeLocalPlayerJoined() {
|
||||||
|
NotifyPlayerJoined(m_pIQNet->GetLocalPlayerByUserIndex(0));
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -4,110 +4,104 @@
|
||||||
#include "Sony/SQRNetworkManager.h"
|
#include "Sony/SQRNetworkManager.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
// A struct that we store in the QoS data when we are hosting the session. Max
|
||||||
// A struct that we store in the QoS data when we are hosting the session. Max size 1020 bytes.
|
// size 1020 bytes.
|
||||||
#ifdef _XBOX
|
#ifdef _XBOX
|
||||||
typedef struct _GameSessionData
|
typedef struct _GameSessionData {
|
||||||
{
|
unsigned short netVersion; // 2 bytes
|
||||||
unsigned short netVersion; // 2 bytes
|
char hostName[XUSER_NAME_SIZE]; // 16 bytes ( 16*1 )
|
||||||
char hostName[XUSER_NAME_SIZE]; // 16 bytes ( 16*1 )
|
GameSessionUID hostPlayerUID; // 8 bytes ( 8*1 ) on xbox, 24 bytes on PS3
|
||||||
GameSessionUID hostPlayerUID; // 8 bytes ( 8*1 ) on xbox, 24 bytes on PS3
|
GameSessionUID
|
||||||
GameSessionUID players[MINECRAFT_NET_MAX_PLAYERS]; // 64 bytes ( 8*8 ) on xbox, 192 ( 24*8) on PS3
|
players[MINECRAFT_NET_MAX_PLAYERS]; // 64 bytes ( 8*8 ) on xbox, 192 (
|
||||||
char szPlayers[MINECRAFT_NET_MAX_PLAYERS][XUSER_NAME_SIZE]; // 128 bytes ( 8*16)
|
// 24*8) on PS3
|
||||||
unsigned int m_uiGameHostSettings; // 4 bytes
|
char szPlayers[MINECRAFT_NET_MAX_PLAYERS]
|
||||||
unsigned int texturePackParentId; // 4 bytes
|
[XUSER_NAME_SIZE]; // 128 bytes ( 8*16)
|
||||||
unsigned char subTexturePackId; // 1 byte
|
unsigned int m_uiGameHostSettings; // 4 bytes
|
||||||
|
unsigned int texturePackParentId; // 4 bytes
|
||||||
|
unsigned char subTexturePackId; // 1 byte
|
||||||
|
|
||||||
bool isJoinable; // 1 byte
|
bool isJoinable; // 1 byte
|
||||||
|
|
||||||
_GameSessionData()
|
_GameSessionData() {
|
||||||
{
|
netVersion = 0;
|
||||||
netVersion = 0;
|
memset(hostName, 0, XUSER_NAME_SIZE);
|
||||||
memset(hostName,0,XUSER_NAME_SIZE);
|
memset(players, 0, MINECRAFT_NET_MAX_PLAYERS * sizeof(players[0]));
|
||||||
memset(players,0,MINECRAFT_NET_MAX_PLAYERS*sizeof(players[0]));
|
memset(szPlayers, 0, MINECRAFT_NET_MAX_PLAYERS * XUSER_NAME_SIZE);
|
||||||
memset(szPlayers,0,MINECRAFT_NET_MAX_PLAYERS*XUSER_NAME_SIZE);
|
isJoinable = true;
|
||||||
isJoinable = true;
|
m_uiGameHostSettings = 0;
|
||||||
m_uiGameHostSettings = 0;
|
texturePackParentId = 0;
|
||||||
texturePackParentId = 0;
|
subTexturePackId = 0;
|
||||||
subTexturePackId = 0;
|
}
|
||||||
}
|
|
||||||
} GameSessionData;
|
} GameSessionData;
|
||||||
#elif defined __PS3__ || defined __ORBIS__ || defined(__PSVITA__)
|
#elif defined __PS3__ || defined __ORBIS__ || defined(__PSVITA__)
|
||||||
typedef struct _GameSessionData
|
typedef struct _GameSessionData {
|
||||||
{
|
unsigned short netVersion; // 2 bytes
|
||||||
unsigned short netVersion; // 2 bytes
|
GameSessionUID hostPlayerUID; // 8 bytes ( 8*1 ) on xbox, 24 bytes on PS3
|
||||||
GameSessionUID hostPlayerUID; // 8 bytes ( 8*1 ) on xbox, 24 bytes on PS3
|
GameSessionUID
|
||||||
GameSessionUID players[MINECRAFT_NET_MAX_PLAYERS]; // 64 bytes ( 8*8 ) on xbox, 192 ( 24*8) on PS3
|
players[MINECRAFT_NET_MAX_PLAYERS]; // 64 bytes ( 8*8 ) on xbox, 192 (
|
||||||
unsigned int m_uiGameHostSettings; // 4 bytes
|
// 24*8) on PS3
|
||||||
unsigned int texturePackParentId; // 4 bytes
|
unsigned int m_uiGameHostSettings; // 4 bytes
|
||||||
unsigned char subTexturePackId; // 1 byte
|
unsigned int texturePackParentId; // 4 bytes
|
||||||
|
unsigned char subTexturePackId; // 1 byte
|
||||||
|
|
||||||
bool isJoinable; // 1 byte
|
bool isJoinable; // 1 byte
|
||||||
|
|
||||||
unsigned char playerCount; // 1 byte
|
unsigned char playerCount; // 1 byte
|
||||||
bool isReadyToJoin; // 1 byte
|
bool isReadyToJoin; // 1 byte
|
||||||
|
|
||||||
_GameSessionData()
|
_GameSessionData() {
|
||||||
{
|
netVersion = 0;
|
||||||
netVersion = 0;
|
memset(players, 0, MINECRAFT_NET_MAX_PLAYERS * sizeof(players[0]));
|
||||||
memset(players,0,MINECRAFT_NET_MAX_PLAYERS*sizeof(players[0]));
|
isJoinable = true;
|
||||||
isJoinable = true;
|
m_uiGameHostSettings = 0;
|
||||||
m_uiGameHostSettings = 0;
|
texturePackParentId = 0;
|
||||||
texturePackParentId = 0;
|
subTexturePackId = 0;
|
||||||
subTexturePackId = 0;
|
playerCount = 0;
|
||||||
playerCount = 0;
|
isReadyToJoin = false;
|
||||||
isReadyToJoin = false;
|
}
|
||||||
|
|
||||||
}
|
|
||||||
} GameSessionData;
|
} GameSessionData;
|
||||||
#else
|
#else
|
||||||
typedef struct _GameSessionData
|
typedef struct _GameSessionData {
|
||||||
{
|
unsigned short netVersion; // 2 bytes
|
||||||
unsigned short netVersion; // 2 bytes
|
unsigned int m_uiGameHostSettings; // 4 bytes
|
||||||
unsigned int m_uiGameHostSettings; // 4 bytes
|
unsigned int texturePackParentId; // 4 bytes
|
||||||
unsigned int texturePackParentId; // 4 bytes
|
unsigned char subTexturePackId; // 1 byte
|
||||||
unsigned char subTexturePackId; // 1 byte
|
|
||||||
|
|
||||||
bool isReadyToJoin; // 1 byte
|
bool isReadyToJoin; // 1 byte
|
||||||
|
|
||||||
_GameSessionData()
|
_GameSessionData() {
|
||||||
{
|
netVersion = 0;
|
||||||
netVersion = 0;
|
m_uiGameHostSettings = 0;
|
||||||
m_uiGameHostSettings = 0;
|
texturePackParentId = 0;
|
||||||
texturePackParentId = 0;
|
subTexturePackId = 0;
|
||||||
subTexturePackId = 0;
|
}
|
||||||
}
|
|
||||||
} GameSessionData;
|
} GameSessionData;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
class FriendSessionInfo
|
class FriendSessionInfo {
|
||||||
{
|
|
||||||
public:
|
public:
|
||||||
SessionID sessionId;
|
SessionID sessionId;
|
||||||
#ifdef _XBOX
|
#ifdef _XBOX
|
||||||
XSESSION_SEARCHRESULT searchResult;
|
XSESSION_SEARCHRESULT searchResult;
|
||||||
#elif defined(__PS3__) || defined(__ORBIS__) || defined (__PSVITA__)
|
#elif defined(__PS3__) || defined(__ORBIS__) || defined(__PSVITA__)
|
||||||
SQRNetworkManager::SessionSearchResult searchResult;
|
SQRNetworkManager::SessionSearchResult searchResult;
|
||||||
#elif defined(_DURANGO)
|
#elif defined(_DURANGO)
|
||||||
DQRNetworkManager::SessionSearchResult searchResult;
|
DQRNetworkManager::SessionSearchResult searchResult;
|
||||||
#endif
|
#endif
|
||||||
wchar_t *displayLabel;
|
wchar_t* displayLabel;
|
||||||
unsigned char displayLabelLength;
|
unsigned char displayLabelLength;
|
||||||
unsigned char displayLabelViewableStartIndex;
|
unsigned char displayLabelViewableStartIndex;
|
||||||
GameSessionData data;
|
GameSessionData data;
|
||||||
bool hasPartyMember;
|
bool hasPartyMember;
|
||||||
|
|
||||||
FriendSessionInfo()
|
FriendSessionInfo() {
|
||||||
{
|
displayLabel = NULL;
|
||||||
displayLabel = NULL;
|
displayLabelLength = 0;
|
||||||
displayLabelLength = 0;
|
displayLabelViewableStartIndex = 0;
|
||||||
displayLabelViewableStartIndex = 0;
|
hasPartyMember = false;
|
||||||
hasPartyMember = false;
|
}
|
||||||
}
|
|
||||||
|
|
||||||
~FriendSessionInfo()
|
~FriendSessionInfo() {
|
||||||
{
|
if (displayLabel != NULL) delete displayLabel;
|
||||||
if(displayLabel!=NULL)
|
}
|
||||||
delete displayLabel;
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -1,114 +1,80 @@
|
||||||
#include "../../../Minecraft.World/Platform/stdafx.h"
|
#include "../../../Minecraft.World/Platform/stdafx.h"
|
||||||
#include "NetworkPlayerSony.h"
|
#include "NetworkPlayerSony.h"
|
||||||
|
|
||||||
NetworkPlayerSony::NetworkPlayerSony(SQRNetworkPlayer *qnetPlayer)
|
NetworkPlayerSony::NetworkPlayerSony(SQRNetworkPlayer* qnetPlayer) {
|
||||||
{
|
m_sqrPlayer = qnetPlayer;
|
||||||
m_sqrPlayer = qnetPlayer;
|
m_pSocket = NULL;
|
||||||
m_pSocket = NULL;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
unsigned char NetworkPlayerSony::GetSmallId()
|
unsigned char NetworkPlayerSony::GetSmallId() {
|
||||||
{
|
return m_sqrPlayer->GetSmallId();
|
||||||
return m_sqrPlayer->GetSmallId();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void NetworkPlayerSony::SendData(INetworkPlayer *player, const void *pvData, int dataSize, bool lowPriority)
|
void NetworkPlayerSony::SendData(INetworkPlayer* player, const void* pvData,
|
||||||
{
|
int dataSize, bool lowPriority) {
|
||||||
// TODO - handle priority
|
// TODO - handle priority
|
||||||
m_sqrPlayer->SendData( ((NetworkPlayerSony *)player)->m_sqrPlayer, pvData, dataSize );
|
m_sqrPlayer->SendData(((NetworkPlayerSony*)player)->m_sqrPlayer, pvData,
|
||||||
|
dataSize);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool NetworkPlayerSony::IsSameSystem(INetworkPlayer *player)
|
bool NetworkPlayerSony::IsSameSystem(INetworkPlayer* player) {
|
||||||
{
|
return m_sqrPlayer->IsSameSystem(((NetworkPlayerSony*)player)->m_sqrPlayer);
|
||||||
return m_sqrPlayer->IsSameSystem(((NetworkPlayerSony *)player)->m_sqrPlayer);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int NetworkPlayerSony::GetSendQueueSizeBytes( INetworkPlayer *player, bool lowPriority )
|
int NetworkPlayerSony::GetSendQueueSizeBytes(INetworkPlayer* player,
|
||||||
{
|
bool lowPriority) {
|
||||||
return 0; // TODO
|
return 0; // TODO
|
||||||
}
|
}
|
||||||
|
|
||||||
int NetworkPlayerSony::GetSendQueueSizeMessages( INetworkPlayer *player, bool lowPriority )
|
int NetworkPlayerSony::GetSendQueueSizeMessages(INetworkPlayer* player,
|
||||||
{
|
bool lowPriority) {
|
||||||
return 0; // TODO
|
return 0; // TODO
|
||||||
}
|
}
|
||||||
|
|
||||||
int NetworkPlayerSony::GetCurrentRtt()
|
int NetworkPlayerSony::GetCurrentRtt() {
|
||||||
{
|
return 0; // TODO
|
||||||
return 0; // TODO
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool NetworkPlayerSony::IsHost()
|
bool NetworkPlayerSony::IsHost() { return m_sqrPlayer->IsHost(); }
|
||||||
{
|
|
||||||
return m_sqrPlayer->IsHost();
|
bool NetworkPlayerSony::IsGuest() {
|
||||||
|
return false; // TODO
|
||||||
}
|
}
|
||||||
|
|
||||||
bool NetworkPlayerSony::IsGuest()
|
bool NetworkPlayerSony::IsLocal() { return m_sqrPlayer->IsLocal(); }
|
||||||
{
|
|
||||||
return false; // TODO
|
int NetworkPlayerSony::GetSessionIndex() {
|
||||||
|
return m_sqrPlayer->GetSessionIndex();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool NetworkPlayerSony::IsLocal()
|
bool NetworkPlayerSony::IsTalking() { return m_sqrPlayer->IsTalking(); }
|
||||||
{
|
|
||||||
return m_sqrPlayer->IsLocal();
|
bool NetworkPlayerSony::IsMutedByLocalUser(int userIndex) {
|
||||||
|
return m_sqrPlayer->IsMutedByLocalUser(userIndex);
|
||||||
}
|
}
|
||||||
|
|
||||||
int NetworkPlayerSony::GetSessionIndex()
|
bool NetworkPlayerSony::HasVoice() { return m_sqrPlayer->HasVoice(); }
|
||||||
{
|
|
||||||
return m_sqrPlayer->GetSessionIndex();
|
bool NetworkPlayerSony::HasCamera() {
|
||||||
|
return false; // TODO
|
||||||
}
|
}
|
||||||
|
|
||||||
bool NetworkPlayerSony::IsTalking()
|
int NetworkPlayerSony::GetUserIndex() {
|
||||||
{
|
return m_sqrPlayer->GetLocalPlayerIndex();
|
||||||
return m_sqrPlayer->IsTalking();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool NetworkPlayerSony::IsMutedByLocalUser(int userIndex)
|
void NetworkPlayerSony::SetSocket(Socket* pSocket) { m_pSocket = pSocket; }
|
||||||
{
|
|
||||||
return m_sqrPlayer->IsMutedByLocalUser(userIndex);
|
Socket* NetworkPlayerSony::GetSocket() { return m_pSocket; }
|
||||||
|
|
||||||
|
const wchar_t* NetworkPlayerSony::GetOnlineName() {
|
||||||
|
return m_sqrPlayer->GetName();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool NetworkPlayerSony::HasVoice()
|
std::wstring NetworkPlayerSony::GetDisplayName() {
|
||||||
{
|
return m_sqrPlayer->GetName();
|
||||||
return m_sqrPlayer->HasVoice();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool NetworkPlayerSony::HasCamera()
|
PlayerUID NetworkPlayerSony::GetUID() { return m_sqrPlayer->GetUID(); }
|
||||||
{
|
|
||||||
return false; // TODO
|
|
||||||
}
|
|
||||||
|
|
||||||
int NetworkPlayerSony::GetUserIndex()
|
void NetworkPlayerSony::SetUID(PlayerUID UID) { m_sqrPlayer->SetUID(UID); }
|
||||||
{
|
|
||||||
return m_sqrPlayer->GetLocalPlayerIndex();
|
|
||||||
}
|
|
||||||
|
|
||||||
void NetworkPlayerSony::SetSocket(Socket *pSocket)
|
|
||||||
{
|
|
||||||
m_pSocket = pSocket;
|
|
||||||
}
|
|
||||||
|
|
||||||
Socket *NetworkPlayerSony::GetSocket()
|
|
||||||
{
|
|
||||||
return m_pSocket;
|
|
||||||
}
|
|
||||||
|
|
||||||
const wchar_t *NetworkPlayerSony::GetOnlineName()
|
|
||||||
{
|
|
||||||
return m_sqrPlayer->GetName();
|
|
||||||
}
|
|
||||||
|
|
||||||
std::wstring NetworkPlayerSony::GetDisplayName()
|
|
||||||
{
|
|
||||||
return m_sqrPlayer->GetName();
|
|
||||||
}
|
|
||||||
|
|
||||||
PlayerUID NetworkPlayerSony::GetUID()
|
|
||||||
{
|
|
||||||
return m_sqrPlayer->GetUID();
|
|
||||||
}
|
|
||||||
|
|
||||||
void NetworkPlayerSony::SetUID(PlayerUID UID)
|
|
||||||
{
|
|
||||||
m_sqrPlayer->SetUID(UID);
|
|
||||||
}
|
|
||||||
|
|
|
||||||
|
|
@ -3,37 +3,40 @@
|
||||||
#include "../NetworkPlayerInterface.h"
|
#include "../NetworkPlayerInterface.h"
|
||||||
#include "SQRNetworkPlayer.h"
|
#include "SQRNetworkPlayer.h"
|
||||||
|
|
||||||
// This is an implementation of the INetworkPlayer interface, for Sony platforms. It effectively wraps the SQRNetworkPlayer class in a non-platform-specific way.
|
// This is an implementation of the INetworkPlayer interface, for Sony
|
||||||
|
// platforms. It effectively wraps the SQRNetworkPlayer class in a
|
||||||
|
// non-platform-specific way.
|
||||||
|
|
||||||
class NetworkPlayerSony : public INetworkPlayer
|
class NetworkPlayerSony : public INetworkPlayer {
|
||||||
{
|
|
||||||
public:
|
public:
|
||||||
// Common player interface
|
// Common player interface
|
||||||
NetworkPlayerSony(SQRNetworkPlayer *sqrPlayer);
|
NetworkPlayerSony(SQRNetworkPlayer* sqrPlayer);
|
||||||
virtual unsigned char GetSmallId();
|
virtual unsigned char GetSmallId();
|
||||||
virtual void SendData(INetworkPlayer *player, const void *pvData, int dataSize, bool lowPriority);
|
virtual void SendData(INetworkPlayer* player, const void* pvData,
|
||||||
virtual bool IsSameSystem(INetworkPlayer *player);
|
int dataSize, bool lowPriority);
|
||||||
virtual int GetSendQueueSizeBytes( INetworkPlayer *player, bool lowPriority );
|
virtual bool IsSameSystem(INetworkPlayer* player);
|
||||||
virtual int GetSendQueueSizeMessages( INetworkPlayer *player, bool lowPriority );
|
virtual int GetSendQueueSizeBytes(INetworkPlayer* player, bool lowPriority);
|
||||||
virtual int GetCurrentRtt();
|
virtual int GetSendQueueSizeMessages(INetworkPlayer* player,
|
||||||
virtual bool IsHost();
|
bool lowPriority);
|
||||||
virtual bool IsGuest();
|
virtual int GetCurrentRtt();
|
||||||
virtual bool IsLocal();
|
virtual bool IsHost();
|
||||||
virtual int GetSessionIndex();
|
virtual bool IsGuest();
|
||||||
virtual bool IsTalking();
|
virtual bool IsLocal();
|
||||||
virtual bool IsMutedByLocalUser(int userIndex);
|
virtual int GetSessionIndex();
|
||||||
virtual bool HasVoice();
|
virtual bool IsTalking();
|
||||||
virtual bool HasCamera();
|
virtual bool IsMutedByLocalUser(int userIndex);
|
||||||
virtual int GetUserIndex();
|
virtual bool HasVoice();
|
||||||
virtual void SetSocket(Socket *pSocket);
|
virtual bool HasCamera();
|
||||||
virtual Socket *GetSocket();
|
virtual int GetUserIndex();
|
||||||
virtual const wchar_t *GetOnlineName();
|
virtual void SetSocket(Socket* pSocket);
|
||||||
virtual std::wstring GetDisplayName();
|
virtual Socket* GetSocket();
|
||||||
virtual PlayerUID GetUID();
|
virtual const wchar_t* GetOnlineName();
|
||||||
|
virtual std::wstring GetDisplayName();
|
||||||
|
virtual PlayerUID GetUID();
|
||||||
|
|
||||||
void SetUID(PlayerUID UID);
|
void SetUID(PlayerUID UID);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
SQRNetworkPlayer *m_sqrPlayer;
|
SQRNetworkPlayer* m_sqrPlayer;
|
||||||
Socket *m_pSocket;
|
Socket* m_pSocket;
|
||||||
};
|
};
|
||||||
|
|
|
||||||
File diff suppressed because it is too large
Load diff
|
|
@ -1,5 +1,5 @@
|
||||||
#pragma once
|
#pragma once
|
||||||
//using namespace std;
|
// using namespace std;
|
||||||
#include <vector>
|
#include <vector>
|
||||||
#include "../../../Minecraft.World/Util/C4JThread.h"
|
#include "../../../Minecraft.World/Util/C4JThread.h"
|
||||||
#include "../NetworkPlayerInterface.h"
|
#include "../NetworkPlayerInterface.h"
|
||||||
|
|
@ -10,178 +10,220 @@
|
||||||
// This is how often we allow a search for new games
|
// This is how often we allow a search for new games
|
||||||
#define MINECRAFT_PS3ROOM_SEARCH_DELAY_MILLISECONDS 30000
|
#define MINECRAFT_PS3ROOM_SEARCH_DELAY_MILLISECONDS 30000
|
||||||
|
|
||||||
// This is the Sony platform specific implementation of CPlatformNetworkManager. It is implemented using SQRNetworkManager/SQRNetworkPlayer. There shouldn't be any general game code in here,
|
// This is the Sony platform specific implementation of CPlatformNetworkManager.
|
||||||
// this class is for providing a bridge between the common game-side network implementation, and the lowest level platform specific libraries.
|
// It is implemented using SQRNetworkManager/SQRNetworkPlayer. There shouldn't
|
||||||
|
// be any general game code in here, this class is for providing a bridge
|
||||||
|
// between the common game-side network implementation, and the lowest level
|
||||||
|
// platform specific libraries.
|
||||||
|
|
||||||
|
class CPlatformNetworkManagerSony : public CPlatformNetworkManager,
|
||||||
|
ISQRNetworkManagerListener {
|
||||||
|
friend class CGameNetworkManager;
|
||||||
|
|
||||||
class CPlatformNetworkManagerSony : public CPlatformNetworkManager, ISQRNetworkManagerListener
|
|
||||||
{
|
|
||||||
friend class CGameNetworkManager;
|
|
||||||
public:
|
public:
|
||||||
virtual bool Initialise(CGameNetworkManager *pGameNetworkManager, int flagIndexSize);
|
virtual bool Initialise(CGameNetworkManager* pGameNetworkManager,
|
||||||
virtual void Terminate();
|
int flagIndexSize);
|
||||||
virtual int GetJoiningReadyPercentage();
|
virtual void Terminate();
|
||||||
virtual int CorrectErrorIDS(int IDS);
|
virtual int GetJoiningReadyPercentage();
|
||||||
|
virtual int CorrectErrorIDS(int IDS);
|
||||||
|
|
||||||
virtual void DoWork();
|
virtual void DoWork();
|
||||||
virtual int GetPlayerCount();
|
virtual int GetPlayerCount();
|
||||||
virtual int GetOnlinePlayerCount();
|
virtual int GetOnlinePlayerCount();
|
||||||
virtual int GetLocalPlayerMask(int playerIndex);
|
virtual int GetLocalPlayerMask(int playerIndex);
|
||||||
virtual bool AddLocalPlayerByUserIndex( int userIndex );
|
virtual bool AddLocalPlayerByUserIndex(int userIndex);
|
||||||
virtual bool RemoveLocalPlayerByUserIndex( int userIndex );
|
virtual bool RemoveLocalPlayerByUserIndex(int userIndex);
|
||||||
virtual INetworkPlayer *GetLocalPlayerByUserIndex( int userIndex );
|
virtual INetworkPlayer* GetLocalPlayerByUserIndex(int userIndex);
|
||||||
virtual INetworkPlayer *GetPlayerByIndex(int playerIndex);
|
virtual INetworkPlayer* GetPlayerByIndex(int playerIndex);
|
||||||
virtual INetworkPlayer * GetPlayerByXuid(PlayerUID xuid);
|
virtual INetworkPlayer* GetPlayerByXuid(PlayerUID xuid);
|
||||||
virtual INetworkPlayer * GetPlayerBySmallId(unsigned char smallId);
|
virtual INetworkPlayer* GetPlayerBySmallId(unsigned char smallId);
|
||||||
virtual bool ShouldMessageForFullSession();
|
virtual bool ShouldMessageForFullSession();
|
||||||
|
|
||||||
virtual INetworkPlayer *GetHostPlayer();
|
virtual INetworkPlayer* GetHostPlayer();
|
||||||
virtual bool IsHost();
|
virtual bool IsHost();
|
||||||
virtual bool JoinGameFromInviteInfo( int userIndex, int userMask, const INVITE_INFO *pInviteInfo);
|
virtual bool JoinGameFromInviteInfo(int userIndex, int userMask,
|
||||||
virtual bool LeaveGame(bool bMigrateHost);
|
const INVITE_INFO* pInviteInfo);
|
||||||
|
virtual bool LeaveGame(bool bMigrateHost);
|
||||||
|
|
||||||
virtual bool IsInSession();
|
virtual bool IsInSession();
|
||||||
virtual bool IsInGameplay();
|
virtual bool IsInGameplay();
|
||||||
virtual bool IsReadyToPlayOrIdle();
|
virtual bool IsReadyToPlayOrIdle();
|
||||||
virtual bool IsInStatsEnabledSession();
|
virtual bool IsInStatsEnabledSession();
|
||||||
virtual bool SessionHasSpace(unsigned int spaceRequired = 1);
|
virtual bool SessionHasSpace(unsigned int spaceRequired = 1);
|
||||||
|
|
||||||
virtual void SendInviteGUI(int quadrant);
|
virtual void SendInviteGUI(int quadrant);
|
||||||
virtual bool IsAddingPlayer();
|
virtual bool IsAddingPlayer();
|
||||||
|
|
||||||
virtual void HostGame(int localUsersMask, bool bOnlineGame, bool bIsPrivate, unsigned char publicSlots = MINECRAFT_NET_MAX_PLAYERS, unsigned char privateSlots = 0);
|
virtual void HostGame(int localUsersMask, bool bOnlineGame, bool bIsPrivate,
|
||||||
virtual int JoinGame(FriendSessionInfo *searchResult, int localUsersMask, int primaryUserIndex );
|
unsigned char publicSlots = MINECRAFT_NET_MAX_PLAYERS,
|
||||||
virtual bool SetLocalGame(bool isLocal);
|
unsigned char privateSlots = 0);
|
||||||
virtual bool IsLocalGame();
|
virtual int JoinGame(FriendSessionInfo* searchResult, int localUsersMask,
|
||||||
virtual void SetPrivateGame(bool isPrivate);
|
int primaryUserIndex);
|
||||||
virtual bool IsPrivateGame();
|
virtual bool SetLocalGame(bool isLocal);
|
||||||
virtual bool IsLeavingGame();
|
virtual bool IsLocalGame();
|
||||||
virtual void ResetLeavingGame();
|
virtual void SetPrivateGame(bool isPrivate);
|
||||||
|
virtual bool IsPrivateGame();
|
||||||
|
virtual bool IsLeavingGame();
|
||||||
|
virtual void ResetLeavingGame();
|
||||||
|
|
||||||
virtual void RegisterPlayerChangedCallback(int iPad, void (*callback)(void *callbackParam, INetworkPlayer *pPlayer, bool leaving), void *callbackParam);
|
virtual void RegisterPlayerChangedCallback(
|
||||||
virtual void UnRegisterPlayerChangedCallback(int iPad, void (*callback)(void *callbackParam, INetworkPlayer *pPlayer, bool leaving), void *callbackParam);
|
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 void HandleSignInChange();
|
||||||
|
|
||||||
virtual bool _RunNetworkGame();
|
virtual bool _RunNetworkGame();
|
||||||
|
|
||||||
#ifdef __PSVITA__
|
#ifdef __PSVITA__
|
||||||
bool usingAdhocMode() { return m_bUsingAdhocMode; }
|
bool usingAdhocMode() { return m_bUsingAdhocMode; }
|
||||||
bool setAdhocMode(bool bAdhoc);
|
bool setAdhocMode(bool bAdhoc);
|
||||||
void startAdhocMatching();
|
void startAdhocMatching();
|
||||||
bool checkValidInviteData(const INVITE_INFO* pInviteInfo);
|
bool checkValidInviteData(const INVITE_INFO* pInviteInfo);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
private:
|
private:
|
||||||
bool isSystemPrimaryPlayer(SQRNetworkPlayer *pQNetPlayer);
|
bool isSystemPrimaryPlayer(SQRNetworkPlayer* pQNetPlayer);
|
||||||
virtual bool _LeaveGame(bool bMigrateHost, bool bLeaveRoom);
|
virtual bool _LeaveGame(bool bMigrateHost, bool bLeaveRoom);
|
||||||
virtual void _HostGame(int dwUsersMask, unsigned char publicSlots = MINECRAFT_NET_MAX_PLAYERS, unsigned char privateSlots = 0);
|
virtual void _HostGame(
|
||||||
virtual bool _StartGame();
|
int dwUsersMask, unsigned char publicSlots = MINECRAFT_NET_MAX_PLAYERS,
|
||||||
|
unsigned char privateSlots = 0);
|
||||||
|
virtual bool _StartGame();
|
||||||
|
|
||||||
#ifdef __PSVITA__
|
#ifdef __PSVITA__
|
||||||
bool m_bUsingAdhocMode;
|
bool m_bUsingAdhocMode;
|
||||||
SQRNetworkManager_Vita* m_pSQRNet_Vita;
|
SQRNetworkManager_Vita* m_pSQRNet_Vita;
|
||||||
SQRNetworkManager_AdHoc_Vita* m_pSQRNet_Vita_Adhoc;
|
SQRNetworkManager_AdHoc_Vita* m_pSQRNet_Vita_Adhoc;
|
||||||
#endif
|
#endif
|
||||||
SQRNetworkManager * m_pSQRNet; // pointer to SQRNetworkManager interface
|
SQRNetworkManager* m_pSQRNet; // pointer to SQRNetworkManager interface
|
||||||
|
|
||||||
HANDLE m_notificationListener;
|
HANDLE m_notificationListener;
|
||||||
|
|
||||||
std::vector<SQRNetworkPlayer *> m_machineSQRPrimaryPlayers; // collection of players that we deem to be the main one for that system
|
std::vector<SQRNetworkPlayer*>
|
||||||
|
m_machineSQRPrimaryPlayers; // collection of players that we deem to be
|
||||||
|
// the main one for that system
|
||||||
|
|
||||||
bool m_bLeavingGame;
|
bool m_bLeavingGame;
|
||||||
bool m_bLeaveGameOnTick;
|
bool m_bLeaveGameOnTick;
|
||||||
bool m_migrateHostOnLeave;
|
bool m_migrateHostOnLeave;
|
||||||
bool m_bHostChanged;
|
bool m_bHostChanged;
|
||||||
bool m_bLeaveRoomWhenLeavingGame;
|
bool m_bLeaveRoomWhenLeavingGame;
|
||||||
|
|
||||||
bool m_bIsOfflineGame;
|
bool m_bIsOfflineGame;
|
||||||
bool m_bIsPrivateGame;
|
bool m_bIsPrivateGame;
|
||||||
int m_flagIndexSize;
|
int m_flagIndexSize;
|
||||||
|
|
||||||
|
// This is only maintained by the host, and is not valid on client machines
|
||||||
|
GameSessionData m_hostGameSessionData;
|
||||||
|
CGameNetworkManager* m_pGameNetworkManager;
|
||||||
|
|
||||||
// This is only maintained by the host, and is not valid on client machines
|
|
||||||
GameSessionData m_hostGameSessionData;
|
|
||||||
CGameNetworkManager *m_pGameNetworkManager;
|
|
||||||
public:
|
public:
|
||||||
virtual void UpdateAndSetGameSessionData(INetworkPlayer *pNetworkPlayerLeaving = NULL);
|
virtual void UpdateAndSetGameSessionData(
|
||||||
|
INetworkPlayer* pNetworkPlayerLeaving = NULL);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
// TODO 4J Stu - Do we need to be able to have more than one of these?
|
// 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 (*playerChangedCallback[XUSER_MAX_COUNT])(void* callbackParam,
|
||||||
void *playerChangedCallbackParam[XUSER_MAX_COUNT];
|
INetworkPlayer* pPlayer,
|
||||||
|
bool leaving);
|
||||||
|
void* playerChangedCallbackParam[XUSER_MAX_COUNT];
|
||||||
|
|
||||||
static int RemovePlayerOnSocketClosedThreadProc( void* lpParam );
|
static int RemovePlayerOnSocketClosedThreadProc(void* lpParam);
|
||||||
virtual bool RemoveLocalPlayer( INetworkPlayer *pNetworkPlayer );
|
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();
|
||||||
|
};
|
||||||
|
std::vector<PlayerFlags*> m_playerFlags;
|
||||||
|
void SystemFlagAddPlayer(INetworkPlayer* pNetworkPlayer);
|
||||||
|
void SystemFlagRemovePlayer(INetworkPlayer* pNetworkPlayer);
|
||||||
|
void SystemFlagReset();
|
||||||
|
|
||||||
// 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();
|
|
||||||
};
|
|
||||||
std::vector<PlayerFlags *> m_playerFlags;
|
|
||||||
void SystemFlagAddPlayer(INetworkPlayer *pNetworkPlayer);
|
|
||||||
void SystemFlagRemovePlayer(INetworkPlayer *pNetworkPlayer);
|
|
||||||
void SystemFlagReset();
|
|
||||||
public:
|
public:
|
||||||
virtual void SystemFlagSet(INetworkPlayer *pNetworkPlayer, int index);
|
virtual void SystemFlagSet(INetworkPlayer* pNetworkPlayer, int index);
|
||||||
virtual bool SystemFlagGet(INetworkPlayer *pNetworkPlayer, int index);
|
virtual bool SystemFlagGet(INetworkPlayer* pNetworkPlayer, int index);
|
||||||
|
|
||||||
// For telemetry
|
// For telemetry
|
||||||
private:
|
private:
|
||||||
float m_lastPlayerEventTimeStart;
|
float m_lastPlayerEventTimeStart;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
std::wstring GatherStats();
|
std::wstring GatherStats();
|
||||||
std::wstring GatherRTTStats();
|
std::wstring GatherRTTStats();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
std::vector<FriendSessionInfo *> friendsSessions;
|
std::vector<FriendSessionInfo*> friendsSessions;
|
||||||
|
|
||||||
int m_lastSearchStartTime;
|
|
||||||
|
|
||||||
// The results that will be filled in with the current search
|
int m_lastSearchStartTime;
|
||||||
int m_searchResultsCount;
|
|
||||||
SQRNetworkManager::SessionSearchResult *m_pSearchResults;
|
|
||||||
|
|
||||||
int m_lastSearchPad;
|
// The results that will be filled in with the current search
|
||||||
bool m_bSearchPending;
|
int m_searchResultsCount;
|
||||||
void *m_pSearchParam;
|
SQRNetworkManager::SessionSearchResult* m_pSearchResults;
|
||||||
void (*m_SessionsUpdatedCallback)(void *pParam);
|
|
||||||
|
|
||||||
C4JThread* m_SearchingThread;
|
int m_lastSearchPad;
|
||||||
|
bool m_bSearchPending;
|
||||||
|
void* m_pSearchParam;
|
||||||
|
void (*m_SessionsUpdatedCallback)(void* pParam);
|
||||||
|
|
||||||
void TickSearch();
|
C4JThread* m_SearchingThread;
|
||||||
|
|
||||||
std::vector<INetworkPlayer *>currentNetworkPlayers;
|
void TickSearch();
|
||||||
INetworkPlayer *addNetworkPlayer(SQRNetworkPlayer *pSQRPlayer);
|
|
||||||
void removeNetworkPlayer(SQRNetworkPlayer *pSQRPlayer);
|
|
||||||
static INetworkPlayer *getNetworkPlayer(SQRNetworkPlayer *pSQRPlayer);
|
|
||||||
|
|
||||||
virtual void SetSessionTexturePackParentId( int id );
|
std::vector<INetworkPlayer*> currentNetworkPlayers;
|
||||||
virtual void SetSessionSubTexturePackId( int id );
|
INetworkPlayer* addNetworkPlayer(SQRNetworkPlayer* pSQRPlayer);
|
||||||
virtual void Notify(int ID, ULONG_PTR Param);
|
void removeNetworkPlayer(SQRNetworkPlayer* pSQRPlayer);
|
||||||
|
static INetworkPlayer* getNetworkPlayer(SQRNetworkPlayer* pSQRPlayer);
|
||||||
|
|
||||||
|
virtual void SetSessionTexturePackParentId(int id);
|
||||||
|
virtual void SetSessionSubTexturePackId(int id);
|
||||||
|
virtual void Notify(int ID, ULONG_PTR Param);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
virtual std::vector<FriendSessionInfo *> *GetSessionList(int iPad, int localPlayers, bool partyOnly);
|
virtual std::vector<FriendSessionInfo*>* GetSessionList(int iPad,
|
||||||
virtual bool GetGameSessionInfo(int iPad, SessionID sessionId,FriendSessionInfo *foundSession);
|
int localPlayers,
|
||||||
virtual void SetSessionsUpdatedCallback( void (*SessionsUpdatedCallback)(void *pParam), void *pSearchParam );
|
bool partyOnly);
|
||||||
virtual void GetFullFriendSessionInfo( FriendSessionInfo *foundSession, void (* FriendSessionUpdatedFn)(bool success, void *pParam), void *pParam );
|
virtual bool GetGameSessionInfo(int iPad, SessionID sessionId,
|
||||||
virtual void ForceFriendsSessionRefresh();
|
FriendSessionInfo* foundSession);
|
||||||
|
virtual void SetSessionsUpdatedCallback(
|
||||||
|
void (*SessionsUpdatedCallback)(void* pParam), void* pSearchParam);
|
||||||
|
virtual void GetFullFriendSessionInfo(
|
||||||
|
FriendSessionInfo* foundSession,
|
||||||
|
void (*FriendSessionUpdatedFn)(bool success, void* pParam),
|
||||||
|
void* pParam);
|
||||||
|
virtual void ForceFriendsSessionRefresh();
|
||||||
|
|
||||||
// ... and the new ones that have been converted to ISQRNetworkManagerListener
|
// ... and the new ones that have been converted to
|
||||||
virtual void HandleDataReceived(SQRNetworkPlayer *playerFrom, SQRNetworkPlayer *playerTo, unsigned char *data, unsigned int dataSize);
|
// ISQRNetworkManagerListener
|
||||||
virtual void HandlePlayerJoined(SQRNetworkPlayer *player);
|
virtual void HandleDataReceived(SQRNetworkPlayer* playerFrom,
|
||||||
virtual void HandlePlayerLeaving(SQRNetworkPlayer *player);
|
SQRNetworkPlayer* playerTo,
|
||||||
virtual void HandleStateChange(SQRNetworkManager::eSQRNetworkManagerState oldState, SQRNetworkManager::eSQRNetworkManagerState newState, bool idleReasonIsSessionFull);
|
unsigned char* data, unsigned int dataSize);
|
||||||
virtual void HandleResyncPlayerRequest(SQRNetworkPlayer **aPlayers);
|
virtual void HandlePlayerJoined(SQRNetworkPlayer* player);
|
||||||
virtual void HandleAddLocalPlayerFailed(int idx);
|
virtual void HandlePlayerLeaving(SQRNetworkPlayer* player);
|
||||||
virtual void HandleDisconnect(bool bLostRoomOnly,bool bPSNSignOut=false);
|
virtual void HandleStateChange(
|
||||||
virtual void HandleInviteReceived( int userIndex, const SQRNetworkManager::PresenceSyncInfo *pInviteInfo);
|
SQRNetworkManager::eSQRNetworkManagerState oldState,
|
||||||
|
SQRNetworkManager::eSQRNetworkManagerState newState,
|
||||||
|
bool idleReasonIsSessionFull);
|
||||||
|
virtual void HandleResyncPlayerRequest(SQRNetworkPlayer** aPlayers);
|
||||||
|
virtual void HandleAddLocalPlayerFailed(int idx);
|
||||||
|
virtual void HandleDisconnect(bool bLostRoomOnly, bool bPSNSignOut = false);
|
||||||
|
virtual void HandleInviteReceived(
|
||||||
|
int userIndex, const SQRNetworkManager::PresenceSyncInfo* pInviteInfo);
|
||||||
|
|
||||||
static void SetSQRPresenceInfoFromExtData(SQRNetworkManager::PresenceSyncInfo *presence, void *pExtData, SceNpMatching2RoomId roomId, SceNpMatching2ServerId serverId);
|
static void SetSQRPresenceInfoFromExtData(
|
||||||
static void MallocAndSetExtDataFromSQRPresenceInfo(void **pExtData, SQRNetworkManager::PresenceSyncInfo *presence);
|
SQRNetworkManager::PresenceSyncInfo* presence, void* pExtData,
|
||||||
|
SceNpMatching2RoomId roomId, SceNpMatching2ServerId serverId);
|
||||||
|
static void MallocAndSetExtDataFromSQRPresenceInfo(
|
||||||
|
void** pExtData, SQRNetworkManager::PresenceSyncInfo* presence);
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -4,7 +4,6 @@
|
||||||
|
|
||||||
bool SQRNetworkManager::s_safeToRespondToGameBootInvite = false;
|
bool SQRNetworkManager::s_safeToRespondToGameBootInvite = false;
|
||||||
|
|
||||||
void SQRNetworkManager::SafeToRespondToGameBootInvite()
|
void SQRNetworkManager::SafeToRespondToGameBootInvite() {
|
||||||
{
|
s_safeToRespondToGameBootInvite = true;
|
||||||
s_safeToRespondToGameBootInvite = true;
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -17,297 +17,324 @@ class ISQRNetworkManagerListener;
|
||||||
class SonyVoiceChat;
|
class SonyVoiceChat;
|
||||||
class C4JThread;
|
class C4JThread;
|
||||||
|
|
||||||
// This is the lowest level manager for providing network functionality on Sony platforms. This manages various network activities including the players within a gaming session.
|
// This is the lowest level manager for providing network functionality on Sony
|
||||||
// The game shouldn't directly use this class, it is here to provide functionality required by PlatformNetworkManagerSony.
|
// platforms. This manages various network activities including the players
|
||||||
|
// within a gaming session. The game shouldn't directly use this class, it is
|
||||||
|
// here to provide functionality required by PlatformNetworkManagerSony.
|
||||||
|
|
||||||
class SQRNetworkManager
|
class SQRNetworkManager {
|
||||||
{
|
|
||||||
public:
|
public:
|
||||||
static const int MAX_LOCAL_PLAYER_COUNT = XUSER_MAX_COUNT;
|
static const int MAX_LOCAL_PLAYER_COUNT = XUSER_MAX_COUNT;
|
||||||
static const int MAX_ONLINE_PLAYER_COUNT = MINECRAFT_NET_MAX_PLAYERS;
|
static const int MAX_ONLINE_PLAYER_COUNT = MINECRAFT_NET_MAX_PLAYERS;
|
||||||
|
|
||||||
|
static const int NP_POOL_SIZE = 128 * 1024;
|
||||||
|
|
||||||
static const int NP_POOL_SIZE = 128 * 1024;
|
|
||||||
protected:
|
protected:
|
||||||
friend class SQRNetworkPlayer;
|
friend class SQRNetworkPlayer;
|
||||||
friend class SonyVoiceChat;
|
friend class SonyVoiceChat;
|
||||||
|
|
||||||
|
static const int MAX_FRIENDS = 100;
|
||||||
static const int MAX_FRIENDS = 100;
|
|
||||||
#ifdef __PS3__
|
#ifdef __PS3__
|
||||||
static const int RUDP_THREAD_PRIORITY = 999;
|
static const int RUDP_THREAD_PRIORITY = 999;
|
||||||
#else // __ORBIS_
|
#else // __ORBIS_
|
||||||
static const int RUDP_THREAD_PRIORITY = 500;
|
static const int RUDP_THREAD_PRIORITY = 500;
|
||||||
#endif
|
#endif
|
||||||
static const int RUDP_THREAD_STACK_SIZE = 32878;
|
static const int RUDP_THREAD_STACK_SIZE = 32878;
|
||||||
static const int MAX_SIMULTANEOUS_INVITES = 10;
|
static const int MAX_SIMULTANEOUS_INVITES = 10;
|
||||||
|
|
||||||
|
|
||||||
// This class stores everything about a player that must be synchronised between machines. This syncing is carried out
|
// This class stores everything about a player that must be synchronised
|
||||||
// by the Matching2 lib by using internal room binary data (ie data that is only visible to current members of a room)
|
// between machines. This syncing is carried out by the Matching2 lib by
|
||||||
class PlayerSyncData
|
// using internal room binary data (ie data that is only visible to current
|
||||||
{
|
// members of a room)
|
||||||
public:
|
class PlayerSyncData {
|
||||||
PlayerUID m_UID; // Assigned by the associated player->GetUID()
|
public:
|
||||||
SceNpMatching2RoomMemberId m_roomMemberId; // Assigned by Matching2 lib, we can use to indicate which machine this player belongs to (note - 16 bits)
|
PlayerUID m_UID; // Assigned by the associated player->GetUID()
|
||||||
unsigned char m_smallId; // Assigned by SQRNetworkManager, to attach a permanent id to this player (until we have to wrap round), to match a similar concept in qnet
|
SceNpMatching2RoomMemberId
|
||||||
unsigned char m_localIdx : 4; // Which local player (by controller index) this represents
|
m_roomMemberId; // Assigned by Matching2 lib, we can use to
|
||||||
unsigned char m_playerCount : 4;
|
// indicate which machine this player belongs to
|
||||||
};
|
// (note - 16 bits)
|
||||||
|
unsigned char
|
||||||
|
m_smallId; // Assigned by SQRNetworkManager, to attach a permanent
|
||||||
|
// id to this player (until we have to wrap round), to
|
||||||
|
// match a similar concept in qnet
|
||||||
|
unsigned char m_localIdx
|
||||||
|
: 4; // Which local player (by controller index) this represents
|
||||||
|
unsigned char m_playerCount : 4;
|
||||||
|
};
|
||||||
|
|
||||||
class RoomSyncData
|
class RoomSyncData {
|
||||||
{
|
public:
|
||||||
public:
|
PlayerSyncData players[MAX_ONLINE_PLAYER_COUNT];
|
||||||
PlayerSyncData players[MAX_ONLINE_PLAYER_COUNT];
|
void setPlayerCount(int c) { players[0].m_playerCount = c; }
|
||||||
void setPlayerCount(int c) { players[0].m_playerCount = c;}
|
int getPlayerCount() { return players[0].m_playerCount; }
|
||||||
int getPlayerCount() { return players[0].m_playerCount;}
|
};
|
||||||
};
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
class PresenceSyncInfo
|
class PresenceSyncInfo {
|
||||||
{
|
public:
|
||||||
public:
|
GameSessionUID hostPlayerUID;
|
||||||
GameSessionUID hostPlayerUID;
|
SceNpMatching2RoomId m_RoomId;
|
||||||
SceNpMatching2RoomId m_RoomId;
|
SceNpMatching2ServerId m_ServerId;
|
||||||
SceNpMatching2ServerId m_ServerId;
|
unsigned int texturePackParentId;
|
||||||
unsigned int texturePackParentId;
|
unsigned short netVersion;
|
||||||
unsigned short netVersion;
|
unsigned char subTexturePackId;
|
||||||
unsigned char subTexturePackId;
|
bool inviteOnly;
|
||||||
bool inviteOnly;
|
};
|
||||||
};
|
|
||||||
|
|
||||||
|
// Externally exposed state. All internal states are mapped to one of these
|
||||||
|
// broader states.
|
||||||
|
typedef enum {
|
||||||
|
SNM_STATE_INITIALISING,
|
||||||
|
SNM_STATE_INITIALISE_FAILED,
|
||||||
|
SNM_STATE_IDLE,
|
||||||
|
|
||||||
// Externally exposed state. All internal states are mapped to one of these broader states.
|
SNM_STATE_HOSTING,
|
||||||
typedef enum
|
SNM_STATE_JOINING,
|
||||||
{
|
|
||||||
SNM_STATE_INITIALISING,
|
|
||||||
SNM_STATE_INITIALISE_FAILED,
|
|
||||||
SNM_STATE_IDLE,
|
|
||||||
|
|
||||||
SNM_STATE_HOSTING,
|
SNM_STATE_STARTING,
|
||||||
SNM_STATE_JOINING,
|
SNM_STATE_PLAYING,
|
||||||
|
|
||||||
SNM_STATE_STARTING,
|
SNM_STATE_LEAVING,
|
||||||
SNM_STATE_PLAYING,
|
SNM_STATE_ENDING,
|
||||||
|
} eSQRNetworkManagerState;
|
||||||
|
|
||||||
SNM_STATE_LEAVING,
|
struct SessionID {
|
||||||
SNM_STATE_ENDING,
|
SceNpMatching2RoomId m_RoomId;
|
||||||
} eSQRNetworkManagerState;
|
SceNpMatching2ServerId m_ServerId;
|
||||||
|
};
|
||||||
|
|
||||||
struct SessionID
|
struct SessionSearchResult {
|
||||||
{
|
SceNpId m_NpId;
|
||||||
SceNpMatching2RoomId m_RoomId;
|
SessionID m_sessionId;
|
||||||
SceNpMatching2ServerId m_ServerId;
|
void* m_extData;
|
||||||
};
|
|
||||||
|
|
||||||
struct SessionSearchResult
|
|
||||||
{
|
|
||||||
SceNpId m_NpId;
|
|
||||||
SessionID m_sessionId;
|
|
||||||
void *m_extData;
|
|
||||||
#ifdef __PSVITA__
|
#ifdef __PSVITA__
|
||||||
SceNetInAddr m_netAddr;
|
SceNetInAddr m_netAddr;
|
||||||
#endif
|
#endif
|
||||||
};
|
};
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
// On initialisation, state should transition from
|
||||||
|
// SNM_INT_STATE_UNINITIALISED -> SNM_INT_STATE_SIGNING_IN ->
|
||||||
|
// SNM_INT_STATE_SIGNED_IN -> SNM_INT_STATE_STARTING_CONTEXT ->
|
||||||
|
// SNM_INT_STATE_IDLE. Error indicated if we transition at any point to
|
||||||
|
// SNM_INT_STATE_INITIALISE_FAILED.
|
||||||
|
|
||||||
// On initialisation, state should transition from SNM_INT_STATE_UNINITIALISED -> SNM_INT_STATE_SIGNING_IN -> SNM_INT_STATE_SIGNED_IN -> SNM_INT_STATE_STARTING_CONTEXT -> SNM_INT_STATE_IDLE.
|
// NOTE: If anything changes in here, then the mapping from internal ->
|
||||||
// Error indicated if we transition at any point to SNM_INT_STATE_INITIALISE_FAILED.
|
// external state needs to be updated (m_INTtoEXTStateMappings, defined in
|
||||||
|
// the cpp file)
|
||||||
|
typedef enum {
|
||||||
|
SNM_INT_STATE_UNINITIALISED,
|
||||||
|
SNM_INT_STATE_SIGNING_IN,
|
||||||
|
SNM_INT_STATE_STARTING_CONTEXT,
|
||||||
|
SNM_INT_STATE_INITIALISE_FAILED,
|
||||||
|
|
||||||
// NOTE: If anything changes in here, then the mapping from internal -> external state needs to be updated (m_INTtoEXTStateMappings, defined in the cpp file)
|
SNM_INT_STATE_IDLE,
|
||||||
typedef enum
|
SNM_INT_STATE_IDLE_RECREATING_MATCHING_CONTEXT,
|
||||||
{
|
|
||||||
SNM_INT_STATE_UNINITIALISED,
|
|
||||||
SNM_INT_STATE_SIGNING_IN,
|
|
||||||
SNM_INT_STATE_STARTING_CONTEXT,
|
|
||||||
SNM_INT_STATE_INITIALISE_FAILED,
|
|
||||||
|
|
||||||
SNM_INT_STATE_IDLE,
|
SNM_INT_STATE_HOSTING_STARTING_MATCHING_CONTEXT,
|
||||||
SNM_INT_STATE_IDLE_RECREATING_MATCHING_CONTEXT,
|
SNM_INT_STATE_HOSTING_SEARCHING_FOR_SERVER,
|
||||||
|
SNM_INT_STATE_HOSTING_SERVER_SEARCH_SERVER_ERROR,
|
||||||
|
SNM_INT_STATE_HOSTING_SERVER_FOUND,
|
||||||
|
SNM_INT_STATE_HOSTING_SERVER_SEARCH_CREATING_CONTEXT,
|
||||||
|
SNM_INT_STATE_HOSTING_SERVER_SEARCH_FAILED,
|
||||||
|
|
||||||
SNM_INT_STATE_HOSTING_STARTING_MATCHING_CONTEXT,
|
SNM_INT_STATE_HOSTING_CREATE_ROOM_SEARCHING_FOR_WORLD,
|
||||||
SNM_INT_STATE_HOSTING_SEARCHING_FOR_SERVER,
|
SNM_INT_STATE_HOSTING_CREATE_ROOM_WORLD_FOUND,
|
||||||
SNM_INT_STATE_HOSTING_SERVER_SEARCH_SERVER_ERROR,
|
SNM_INT_STATE_HOSTING_CREATE_ROOM_CREATING_ROOM,
|
||||||
SNM_INT_STATE_HOSTING_SERVER_FOUND,
|
SNM_INT_STATE_HOSTING_CREATE_ROOM_SUCCESS,
|
||||||
SNM_INT_STATE_HOSTING_SERVER_SEARCH_CREATING_CONTEXT,
|
SNM_INT_STATE_HOSTING_CREATE_ROOM_FAILED,
|
||||||
SNM_INT_STATE_HOSTING_SERVER_SEARCH_FAILED,
|
SNM_INT_STATE_HOSTING_CREATE_ROOM_RESTART_MATCHING_CONTEXT,
|
||||||
|
SNM_INT_STATE_HOSTING_WAITING_TO_PLAY,
|
||||||
|
|
||||||
SNM_INT_STATE_HOSTING_CREATE_ROOM_SEARCHING_FOR_WORLD,
|
SNM_INT_STATE_JOINING_STARTING_MATCHING_CONTEXT,
|
||||||
SNM_INT_STATE_HOSTING_CREATE_ROOM_WORLD_FOUND,
|
SNM_INT_STATE_JOINING_SEARCHING_FOR_SERVER,
|
||||||
SNM_INT_STATE_HOSTING_CREATE_ROOM_CREATING_ROOM,
|
SNM_INT_STATE_JOINING_SERVER_SEARCH_SERVER_ERROR,
|
||||||
SNM_INT_STATE_HOSTING_CREATE_ROOM_SUCCESS,
|
SNM_INT_STATE_JOINING_SERVER_FOUND,
|
||||||
SNM_INT_STATE_HOSTING_CREATE_ROOM_FAILED,
|
SNM_INT_STATE_JOINING_SERVER_SEARCH_CREATING_CONTEXT,
|
||||||
SNM_INT_STATE_HOSTING_CREATE_ROOM_RESTART_MATCHING_CONTEXT,
|
SNM_INT_STATE_JOINING_SERVER_SEARCH_FAILED,
|
||||||
SNM_INT_STATE_HOSTING_WAITING_TO_PLAY,
|
|
||||||
|
|
||||||
SNM_INT_STATE_JOINING_STARTING_MATCHING_CONTEXT,
|
SNM_INT_STATE_JOINING_JOIN_ROOM,
|
||||||
SNM_INT_STATE_JOINING_SEARCHING_FOR_SERVER,
|
SNM_INT_STATE_JOINING_JOIN_ROOM_FAILED,
|
||||||
SNM_INT_STATE_JOINING_SERVER_SEARCH_SERVER_ERROR,
|
|
||||||
SNM_INT_STATE_JOINING_SERVER_FOUND,
|
|
||||||
SNM_INT_STATE_JOINING_SERVER_SEARCH_CREATING_CONTEXT,
|
|
||||||
SNM_INT_STATE_JOINING_SERVER_SEARCH_FAILED,
|
|
||||||
|
|
||||||
SNM_INT_STATE_JOINING_JOIN_ROOM,
|
SNM_INT_STATE_JOINING_WAITING_FOR_LOCAL_PLAYERS,
|
||||||
SNM_INT_STATE_JOINING_JOIN_ROOM_FAILED,
|
|
||||||
|
|
||||||
SNM_INT_STATE_JOINING_WAITING_FOR_LOCAL_PLAYERS,
|
SNM_INT_STATE_SERVER_DELETING_CONTEXT,
|
||||||
|
|
||||||
SNM_INT_STATE_SERVER_DELETING_CONTEXT,
|
SNM_INT_STATE_STARTING,
|
||||||
|
SNM_INT_STATE_PLAYING,
|
||||||
|
|
||||||
SNM_INT_STATE_STARTING,
|
SNM_INT_STATE_LEAVING,
|
||||||
SNM_INT_STATE_PLAYING,
|
SNM_INT_STATE_LEAVING_FAILED,
|
||||||
|
|
||||||
SNM_INT_STATE_LEAVING,
|
SNM_INT_STATE_ENDING,
|
||||||
SNM_INT_STATE_LEAVING_FAILED,
|
|
||||||
|
|
||||||
SNM_INT_STATE_ENDING,
|
SNM_INT_STATE_COUNT
|
||||||
|
|
||||||
SNM_INT_STATE_COUNT
|
} eSQRNetworkManagerInternalState;
|
||||||
|
|
||||||
} eSQRNetworkManagerInternalState;
|
|
||||||
|
|
||||||
typedef enum
|
typedef enum {
|
||||||
{
|
SNM_FORCE_ERROR_NP2_INIT,
|
||||||
SNM_FORCE_ERROR_NP2_INIT,
|
SNM_FORCE_ERROR_NET_INITIALIZE_NETWORK,
|
||||||
SNM_FORCE_ERROR_NET_INITIALIZE_NETWORK,
|
SNM_FORCE_ERROR_NET_CTL_INIT,
|
||||||
SNM_FORCE_ERROR_NET_CTL_INIT,
|
SNM_FORCE_ERROR_RUDP_INIT,
|
||||||
SNM_FORCE_ERROR_RUDP_INIT,
|
SNM_FORCE_ERROR_NET_START_DIALOG,
|
||||||
SNM_FORCE_ERROR_NET_START_DIALOG,
|
SNM_FORCE_ERROR_MATCHING2_INIT,
|
||||||
SNM_FORCE_ERROR_MATCHING2_INIT,
|
SNM_FORCE_ERROR_REGISTER_NP_CALLBACK,
|
||||||
SNM_FORCE_ERROR_REGISTER_NP_CALLBACK,
|
SNM_FORCE_ERROR_GET_NPID,
|
||||||
SNM_FORCE_ERROR_GET_NPID,
|
SNM_FORCE_ERROR_CREATE_MATCHING_CONTEXT,
|
||||||
SNM_FORCE_ERROR_CREATE_MATCHING_CONTEXT,
|
SNM_FORCE_ERROR_REGISTER_CALLBACKS,
|
||||||
SNM_FORCE_ERROR_REGISTER_CALLBACKS,
|
SNM_FORCE_ERROR_CONTEXT_START_ASYNC,
|
||||||
SNM_FORCE_ERROR_CONTEXT_START_ASYNC,
|
SNM_FORCE_ERROR_SET_EXTERNAL_ROOM_DATA,
|
||||||
SNM_FORCE_ERROR_SET_EXTERNAL_ROOM_DATA,
|
SNM_FORCE_ERROR_GET_FRIEND_LIST_ENTRY_COUNT,
|
||||||
SNM_FORCE_ERROR_GET_FRIEND_LIST_ENTRY_COUNT,
|
SNM_FORCE_ERROR_GET_FRIEND_LIST_ENTRY,
|
||||||
SNM_FORCE_ERROR_GET_FRIEND_LIST_ENTRY,
|
SNM_FORCE_ERROR_GET_USER_INFO_LIST,
|
||||||
SNM_FORCE_ERROR_GET_USER_INFO_LIST,
|
SNM_FORCE_ERROR_LEAVE_ROOM,
|
||||||
SNM_FORCE_ERROR_LEAVE_ROOM,
|
SNM_FORCE_ERROR_SET_ROOM_MEMBER_DATA_INTERNAL,
|
||||||
SNM_FORCE_ERROR_SET_ROOM_MEMBER_DATA_INTERNAL,
|
SNM_FORCE_ERROR_SET_ROOM_MEMBER_DATA_INTERNAL2,
|
||||||
SNM_FORCE_ERROR_SET_ROOM_MEMBER_DATA_INTERNAL2,
|
SNM_FORCE_ERROR_CREATE_SERVER_CONTEXT,
|
||||||
SNM_FORCE_ERROR_CREATE_SERVER_CONTEXT,
|
SNM_FORCE_ERROR_CREATE_JOIN_ROOM,
|
||||||
SNM_FORCE_ERROR_CREATE_JOIN_ROOM,
|
SNM_FORCE_ERROR_GET_SERVER_INFO,
|
||||||
SNM_FORCE_ERROR_GET_SERVER_INFO,
|
SNM_FORCE_ERROR_DELETE_SERVER_CONTEXT,
|
||||||
SNM_FORCE_ERROR_DELETE_SERVER_CONTEXT,
|
SNM_FORCE_ERROR_SETSOCKOPT_0,
|
||||||
SNM_FORCE_ERROR_SETSOCKOPT_0,
|
SNM_FORCE_ERROR_SETSOCKOPT_1,
|
||||||
SNM_FORCE_ERROR_SETSOCKOPT_1,
|
SNM_FORCE_ERROR_SETSOCKOPT_2,
|
||||||
SNM_FORCE_ERROR_SETSOCKOPT_2,
|
SNM_FORCE_ERROR_SOCK_BIND,
|
||||||
SNM_FORCE_ERROR_SOCK_BIND,
|
SNM_FORCE_ERROR_CREATE_RUDP_CONTEXT,
|
||||||
SNM_FORCE_ERROR_CREATE_RUDP_CONTEXT,
|
SNM_FORCE_ERROR_RUDP_BIND,
|
||||||
SNM_FORCE_ERROR_RUDP_BIND,
|
SNM_FORCE_ERROR_RUDP_INIT2,
|
||||||
SNM_FORCE_ERROR_RUDP_INIT2,
|
SNM_FORCE_ERROR_GET_ROOM_EXTERNAL_DATA,
|
||||||
SNM_FORCE_ERROR_GET_ROOM_EXTERNAL_DATA,
|
SNM_FORCE_ERROR_GET_SERVER_INFO_DATA,
|
||||||
SNM_FORCE_ERROR_GET_SERVER_INFO_DATA,
|
SNM_FORCE_ERROR_GET_WORLD_INFO_DATA,
|
||||||
SNM_FORCE_ERROR_GET_WORLD_INFO_DATA,
|
SNM_FORCE_ERROR_GET_CREATE_JOIN_ROOM_DATA,
|
||||||
SNM_FORCE_ERROR_GET_CREATE_JOIN_ROOM_DATA,
|
SNM_FORCE_ERROR_GET_USER_INFO_LIST_DATA,
|
||||||
SNM_FORCE_ERROR_GET_USER_INFO_LIST_DATA,
|
SNM_FORCE_ERROR_GET_JOIN_ROOM_DATA,
|
||||||
SNM_FORCE_ERROR_GET_JOIN_ROOM_DATA,
|
SNM_FORCE_ERROR_GET_ROOM_MEMBER_DATA_INTERNAL,
|
||||||
SNM_FORCE_ERROR_GET_ROOM_MEMBER_DATA_INTERNAL,
|
SNM_FORCE_ERROR_GET_ROOM_EXTERNAL_DATA2,
|
||||||
SNM_FORCE_ERROR_GET_ROOM_EXTERNAL_DATA2,
|
SNM_FORCE_ERROR_CREATE_SERVER_CONTEXT_CALLBACK,
|
||||||
SNM_FORCE_ERROR_CREATE_SERVER_CONTEXT_CALLBACK,
|
SNM_FORCE_ERROR_SET_ROOM_DATA_CALLBACK,
|
||||||
SNM_FORCE_ERROR_SET_ROOM_DATA_CALLBACK,
|
SNM_FORCE_ERROR_UPDATED_ROOM_DATA,
|
||||||
SNM_FORCE_ERROR_UPDATED_ROOM_DATA,
|
SNM_FORCE_ERROR_UPDATED_ROOM_MEMBER_DATA_INTERNAL1,
|
||||||
SNM_FORCE_ERROR_UPDATED_ROOM_MEMBER_DATA_INTERNAL1,
|
SNM_FORCE_ERROR_UPDATED_ROOM_MEMBER_DATA_INTERNAL2,
|
||||||
SNM_FORCE_ERROR_UPDATED_ROOM_MEMBER_DATA_INTERNAL2,
|
SNM_FORCE_ERROR_UPDATED_ROOM_MEMBER_DATA_INTERNAL3,
|
||||||
SNM_FORCE_ERROR_UPDATED_ROOM_MEMBER_DATA_INTERNAL3,
|
SNM_FORCE_ERROR_UPDATED_ROOM_MEMBER_DATA_INTERNAL4,
|
||||||
SNM_FORCE_ERROR_UPDATED_ROOM_MEMBER_DATA_INTERNAL4,
|
SNM_FORCE_ERROR_GET_WORLD_INFO_LIST,
|
||||||
SNM_FORCE_ERROR_GET_WORLD_INFO_LIST,
|
SNM_FORCE_ERROR_JOIN_ROOM,
|
||||||
SNM_FORCE_ERROR_JOIN_ROOM,
|
|
||||||
|
|
||||||
SNM_FORCE_ERROR_COUNT,
|
SNM_FORCE_ERROR_COUNT,
|
||||||
} eSQRForceError;
|
} eSQRForceError;
|
||||||
|
|
||||||
|
class StateChangeInfo {
|
||||||
|
public:
|
||||||
|
eSQRNetworkManagerState m_oldState;
|
||||||
|
eSQRNetworkManagerState m_newState;
|
||||||
|
bool m_idleReasonIsSessionFull;
|
||||||
|
StateChangeInfo(eSQRNetworkManagerState oldState,
|
||||||
|
eSQRNetworkManagerState newState,
|
||||||
|
bool idleReasonIsSessionFull)
|
||||||
|
: m_oldState(oldState),
|
||||||
|
m_newState(newState),
|
||||||
|
m_idleReasonIsSessionFull(idleReasonIsSessionFull) {}
|
||||||
|
};
|
||||||
|
|
||||||
class StateChangeInfo
|
std::queue<StateChangeInfo> m_stateChangeQueue;
|
||||||
{
|
CRITICAL_SECTION m_csStateChangeQueue;
|
||||||
public:
|
CRITICAL_SECTION m_csMatching;
|
||||||
eSQRNetworkManagerState m_oldState;
|
|
||||||
eSQRNetworkManagerState m_newState;
|
|
||||||
bool m_idleReasonIsSessionFull;
|
|
||||||
StateChangeInfo(eSQRNetworkManagerState oldState, eSQRNetworkManagerState newState,bool idleReasonIsSessionFull) : m_oldState(oldState), m_newState(newState), m_idleReasonIsSessionFull(idleReasonIsSessionFull) {}
|
|
||||||
};
|
|
||||||
|
|
||||||
std::queue<StateChangeInfo> m_stateChangeQueue;
|
typedef enum {
|
||||||
CRITICAL_SECTION m_csStateChangeQueue;
|
SNM_FRIEND_SEARCH_STATE_IDLE, // Idle - search result will be valid
|
||||||
CRITICAL_SECTION m_csMatching;
|
// (although it may not have any entries)
|
||||||
|
SNM_FRIEND_SEARCH_STATE_GETTING_FRIEND_COUNT, // Getting count of
|
||||||
|
// friends in friend list
|
||||||
|
SNM_FRIEND_SEARCH_STATE_GETTING_FRIEND_INFO, // Getting presence/NpId
|
||||||
|
// info for each friend
|
||||||
|
} eSQRNetworkManagerFriendSearchState;
|
||||||
|
|
||||||
typedef enum
|
typedef void (*ServerContextValidCallback)(SQRNetworkManager* manager);
|
||||||
{
|
|
||||||
SNM_FRIEND_SEARCH_STATE_IDLE, // Idle - search result will be valid (although it may not have any entries)
|
|
||||||
SNM_FRIEND_SEARCH_STATE_GETTING_FRIEND_COUNT, // Getting count of friends in friend list
|
|
||||||
SNM_FRIEND_SEARCH_STATE_GETTING_FRIEND_INFO, // Getting presence/NpId info for each friend
|
|
||||||
} eSQRNetworkManagerFriendSearchState;
|
|
||||||
|
|
||||||
typedef void (*ServerContextValidCallback)(SQRNetworkManager *manager);
|
static bool s_safeToRespondToGameBootInvite;
|
||||||
|
|
||||||
static bool s_safeToRespondToGameBootInvite;
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
// General
|
||||||
// General
|
virtual void Tick() = 0;
|
||||||
virtual void Tick() = 0;
|
virtual void Initialise() = 0;
|
||||||
virtual void Initialise() = 0;
|
|
||||||
#ifdef __PSVITA__
|
#ifdef __PSVITA__
|
||||||
virtual void UnInitialise() = 0; // to switch from PSN to Adhoc
|
virtual void UnInitialise() = 0; // to switch from PSN to Adhoc
|
||||||
virtual bool IsInitialised() = 0;
|
virtual bool IsInitialised() = 0;
|
||||||
#endif
|
#endif
|
||||||
virtual void Terminate() = 0;
|
virtual void Terminate() = 0;
|
||||||
virtual eSQRNetworkManagerState GetState() = 0;
|
virtual eSQRNetworkManagerState GetState() = 0;
|
||||||
virtual bool IsHost() = 0;
|
virtual bool IsHost() = 0;
|
||||||
virtual bool IsReadyToPlayOrIdle() = 0;
|
virtual bool IsReadyToPlayOrIdle() = 0;
|
||||||
virtual bool IsInSession() = 0;
|
virtual bool IsInSession() = 0;
|
||||||
|
|
||||||
// Session management
|
// Session management
|
||||||
virtual void CreateAndJoinRoom(int hostIndex, int localPlayerMask, void *extData, int extDataSize, bool offline) = 0;
|
virtual void CreateAndJoinRoom(int hostIndex, int localPlayerMask,
|
||||||
virtual void UpdateExternalRoomData() = 0;
|
void* extData, int extDataSize,
|
||||||
virtual bool FriendRoomManagerIsBusy() = 0;
|
bool offline) = 0;
|
||||||
virtual bool FriendRoomManagerSearch() = 0;
|
virtual void UpdateExternalRoomData() = 0;
|
||||||
virtual bool FriendRoomManagerSearch2() = 0;
|
virtual bool FriendRoomManagerIsBusy() = 0;
|
||||||
virtual int FriendRoomManagerGetCount() = 0;
|
virtual bool FriendRoomManagerSearch() = 0;
|
||||||
virtual void FriendRoomManagerGetRoomInfo(int idx, SessionSearchResult *searchResult) = 0;
|
virtual bool FriendRoomManagerSearch2() = 0;
|
||||||
virtual bool JoinRoom(SessionSearchResult *searchResult, int localPlayerMask) = 0;
|
virtual int FriendRoomManagerGetCount() = 0;
|
||||||
virtual bool JoinRoom(SceNpMatching2RoomId roomId, SceNpMatching2ServerId serverId, int localPlayerMask, const SQRNetworkManager::PresenceSyncInfo *presence) = 0;
|
virtual void FriendRoomManagerGetRoomInfo(
|
||||||
virtual void StartGame() = 0;
|
int idx, SessionSearchResult* searchResult) = 0;
|
||||||
virtual void LeaveRoom(bool bActuallyLeaveRoom) = 0;
|
virtual bool JoinRoom(SessionSearchResult* searchResult,
|
||||||
virtual void EndGame() = 0;
|
int localPlayerMask) = 0;
|
||||||
virtual bool SessionHasSpace(int spaceRequired) = 0;
|
virtual bool JoinRoom(
|
||||||
virtual bool AddLocalPlayerByUserIndex(int idx) = 0;
|
SceNpMatching2RoomId roomId, SceNpMatching2ServerId serverId,
|
||||||
virtual bool RemoveLocalPlayerByUserIndex(int idx) = 0;
|
int localPlayerMask,
|
||||||
virtual void SendInviteGUI() = 0;
|
const SQRNetworkManager::PresenceSyncInfo* presence) = 0;
|
||||||
|
virtual void StartGame() = 0;
|
||||||
|
virtual void LeaveRoom(bool bActuallyLeaveRoom) = 0;
|
||||||
|
virtual void EndGame() = 0;
|
||||||
|
virtual bool SessionHasSpace(int spaceRequired) = 0;
|
||||||
|
virtual bool AddLocalPlayerByUserIndex(int idx) = 0;
|
||||||
|
virtual bool RemoveLocalPlayerByUserIndex(int idx) = 0;
|
||||||
|
virtual void SendInviteGUI() = 0;
|
||||||
|
|
||||||
virtual void GetExtDataForRoom( SceNpMatching2RoomId roomId, void *extData, void (* FriendSessionUpdatedFn)(bool success, void *pParam), void *pParam ) = 0;
|
virtual void GetExtDataForRoom(SceNpMatching2RoomId roomId, void* extData,
|
||||||
|
void (*FriendSessionUpdatedFn)(bool success,
|
||||||
|
void* pParam),
|
||||||
|
void* pParam) = 0;
|
||||||
|
|
||||||
// Player retrieval
|
// Player retrieval
|
||||||
virtual int GetPlayerCount() = 0;
|
virtual int GetPlayerCount() = 0;
|
||||||
virtual int GetOnlinePlayerCount() = 0;
|
virtual int GetOnlinePlayerCount() = 0;
|
||||||
virtual SQRNetworkPlayer *GetPlayerByIndex(int idx) = 0;
|
virtual SQRNetworkPlayer* GetPlayerByIndex(int idx) = 0;
|
||||||
virtual SQRNetworkPlayer *GetPlayerBySmallId(int idx) = 0;
|
virtual SQRNetworkPlayer* GetPlayerBySmallId(int idx) = 0;
|
||||||
virtual SQRNetworkPlayer *GetPlayerByXuid(PlayerUID xuid) = 0;
|
virtual SQRNetworkPlayer* GetPlayerByXuid(PlayerUID xuid) = 0;
|
||||||
virtual SQRNetworkPlayer *GetLocalPlayerByUserIndex(int idx) = 0;
|
virtual SQRNetworkPlayer* GetLocalPlayerByUserIndex(int idx) = 0;
|
||||||
virtual SQRNetworkPlayer *GetHostPlayer() = 0;
|
virtual SQRNetworkPlayer* GetHostPlayer() = 0;
|
||||||
|
|
||||||
virtual void SetPresenceDataStartHostingGame() = 0;
|
virtual void SetPresenceDataStartHostingGame() = 0;
|
||||||
virtual int GetJoiningReadyPercentage() = 0;
|
virtual int GetJoiningReadyPercentage() = 0;
|
||||||
|
|
||||||
virtual void LocalDataSend(SQRNetworkPlayer *playerFrom, SQRNetworkPlayer *playerTo, const void *data, unsigned int dataSize) = 0;
|
virtual void LocalDataSend(SQRNetworkPlayer* playerFrom,
|
||||||
virtual int GetSessionIndex(SQRNetworkPlayer *player) = 0;
|
SQRNetworkPlayer* playerTo, const void* data,
|
||||||
|
unsigned int dataSize) = 0;
|
||||||
static void SafeToRespondToGameBootInvite();
|
virtual int GetSessionIndex(SQRNetworkPlayer* player) = 0;
|
||||||
|
|
||||||
|
static void SafeToRespondToGameBootInvite();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
// Class defining interface to be implemented for class that handles callbacks
|
// Class defining interface to be implemented for class that handles callbacks
|
||||||
class ISQRNetworkManagerListener
|
class ISQRNetworkManagerListener {
|
||||||
{
|
|
||||||
public:
|
public:
|
||||||
virtual void HandleDataReceived(SQRNetworkPlayer *playerFrom, SQRNetworkPlayer *playerTo, unsigned char *data, unsigned int dataSize) = 0;
|
virtual void HandleDataReceived(SQRNetworkPlayer* playerFrom,
|
||||||
virtual void HandlePlayerJoined(SQRNetworkPlayer *player) = 0;
|
SQRNetworkPlayer* playerTo,
|
||||||
virtual void HandlePlayerLeaving(SQRNetworkPlayer *player) = 0;
|
unsigned char* data,
|
||||||
virtual void HandleStateChange(SQRNetworkManager::eSQRNetworkManagerState oldState, SQRNetworkManager::eSQRNetworkManagerState newState, bool idleReasonIsSessionFull) = 0;
|
unsigned int dataSize) = 0;
|
||||||
virtual void HandleResyncPlayerRequest(SQRNetworkPlayer **aPlayers) = 0;
|
virtual void HandlePlayerJoined(SQRNetworkPlayer* player) = 0;
|
||||||
virtual void HandleAddLocalPlayerFailed(int idx) = 0;
|
virtual void HandlePlayerLeaving(SQRNetworkPlayer* player) = 0;
|
||||||
virtual void HandleDisconnect(bool bLostRoomOnly,bool bPSNSignOut=false) = 0;
|
virtual void HandleStateChange(
|
||||||
virtual void HandleInviteReceived( int userIndex, const SQRNetworkManager::PresenceSyncInfo *pInviteInfo) = 0;
|
SQRNetworkManager::eSQRNetworkManagerState oldState,
|
||||||
|
SQRNetworkManager::eSQRNetworkManagerState newState,
|
||||||
|
bool idleReasonIsSessionFull) = 0;
|
||||||
|
virtual void HandleResyncPlayerRequest(SQRNetworkPlayer** aPlayers) = 0;
|
||||||
|
virtual void HandleAddLocalPlayerFailed(int idx) = 0;
|
||||||
|
virtual void HandleDisconnect(bool bLostRoomOnly,
|
||||||
|
bool bPSNSignOut = false) = 0;
|
||||||
|
virtual void HandleInviteReceived(
|
||||||
|
int userIndex,
|
||||||
|
const SQRNetworkManager::PresenceSyncInfo* pInviteInfo) = 0;
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -9,391 +9,360 @@
|
||||||
#include <rudp.h>
|
#include <rudp.h>
|
||||||
#include "../../../../Platform/Orbis/Network/SonyVoiceChat_Orbis.h"
|
#include "../../../../Platform/Orbis/Network/SonyVoiceChat_Orbis.h"
|
||||||
|
|
||||||
#else // __PSVITA__
|
#else // __PSVITA__
|
||||||
#include <rudp.h>
|
#include <rudp.h>
|
||||||
#include <adhoc_matching.h>
|
#include <adhoc_matching.h>
|
||||||
#include "../../../../Platform/PSVita/Network/SonyVoiceChat_Vita.h"
|
#include "../../../../Platform/PSVita/Network/SonyVoiceChat_Vita.h"
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
static const bool sc_verbose = false;
|
static const bool sc_verbose = false;
|
||||||
|
|
||||||
int SQRNetworkPlayer::GetSmallId()
|
int SQRNetworkPlayer::GetSmallId() { return m_ISD.m_smallId; }
|
||||||
{
|
|
||||||
return m_ISD.m_smallId;
|
wchar_t* SQRNetworkPlayer::GetName() { return m_name; }
|
||||||
|
|
||||||
|
bool SQRNetworkPlayer::IsRemote() { return !IsLocal(); }
|
||||||
|
|
||||||
|
bool SQRNetworkPlayer::IsHost() { return (m_type == SNP_TYPE_HOST); }
|
||||||
|
|
||||||
|
bool SQRNetworkPlayer::IsLocal() {
|
||||||
|
// m_host determines whether this *machine* is hosting the game, not this
|
||||||
|
// player (which is determined by m_type)
|
||||||
|
if (m_host) {
|
||||||
|
// If we are the hosting machine, then both the host & local players are
|
||||||
|
// local to this machine
|
||||||
|
return (m_type == SNP_TYPE_HOST) || (m_type == SNP_TYPE_LOCAL);
|
||||||
|
} else {
|
||||||
|
// Not hosting, just local players are actually physically local
|
||||||
|
return (m_type == SNP_TYPE_LOCAL);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
wchar_t *SQRNetworkPlayer::GetName()
|
int SQRNetworkPlayer::GetLocalPlayerIndex() { return m_localPlayerIdx; }
|
||||||
{
|
|
||||||
return m_name;
|
bool SQRNetworkPlayer::IsSameSystem(SQRNetworkPlayer* other) {
|
||||||
|
return (m_roomMemberId == other->m_roomMemberId);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool SQRNetworkPlayer::IsRemote()
|
uintptr_t SQRNetworkPlayer::GetCustomDataValue() { return m_customData; }
|
||||||
{
|
|
||||||
return !IsLocal();
|
void SQRNetworkPlayer::SetCustomDataValue(uintptr_t data) {
|
||||||
|
m_customData = data;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool SQRNetworkPlayer::IsHost()
|
SQRNetworkPlayer::SQRNetworkPlayer(SQRNetworkManager* manager,
|
||||||
{
|
eSQRNetworkPlayerType playerType,
|
||||||
return (m_type == SNP_TYPE_HOST);
|
bool onHost,
|
||||||
}
|
SceNpMatching2RoomMemberId roomMemberId,
|
||||||
|
int localPlayerIdx, int rudpCtx,
|
||||||
bool SQRNetworkPlayer::IsLocal()
|
PlayerUID* pUID) {
|
||||||
{
|
m_roomMemberId = roomMemberId;
|
||||||
// m_host determines whether this *machine* is hosting the game, not this player (which is determined by m_type)
|
m_localPlayerIdx = localPlayerIdx;
|
||||||
if( m_host )
|
m_rudpCtx = rudpCtx;
|
||||||
{
|
m_flags = 0;
|
||||||
// If we are the hosting machine, then both the host & local players are local to this machine
|
m_type = playerType;
|
||||||
return (m_type == SNP_TYPE_HOST) || (m_type == SNP_TYPE_LOCAL);
|
m_host = onHost;
|
||||||
}
|
m_manager = manager;
|
||||||
else
|
m_customData = 0;
|
||||||
{
|
if (pUID) {
|
||||||
// Not hosting, just local players are actually physically local
|
memcpy(&m_ISD.m_UID, pUID, sizeof(PlayerUID));
|
||||||
return (m_type == SNP_TYPE_LOCAL) ;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
int SQRNetworkPlayer::GetLocalPlayerIndex()
|
|
||||||
{
|
|
||||||
return m_localPlayerIdx;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool SQRNetworkPlayer::IsSameSystem(SQRNetworkPlayer *other)
|
|
||||||
{
|
|
||||||
return (m_roomMemberId == other->m_roomMemberId);
|
|
||||||
}
|
|
||||||
|
|
||||||
uintptr_t SQRNetworkPlayer::GetCustomDataValue()
|
|
||||||
{
|
|
||||||
return m_customData;
|
|
||||||
}
|
|
||||||
|
|
||||||
void SQRNetworkPlayer::SetCustomDataValue(uintptr_t data)
|
|
||||||
{
|
|
||||||
m_customData = data;
|
|
||||||
}
|
|
||||||
|
|
||||||
SQRNetworkPlayer::SQRNetworkPlayer(SQRNetworkManager *manager, eSQRNetworkPlayerType playerType, bool onHost, SceNpMatching2RoomMemberId roomMemberId, int localPlayerIdx, int rudpCtx, PlayerUID *pUID)
|
|
||||||
{
|
|
||||||
m_roomMemberId = roomMemberId;
|
|
||||||
m_localPlayerIdx = localPlayerIdx;
|
|
||||||
m_rudpCtx = rudpCtx;
|
|
||||||
m_flags = 0;
|
|
||||||
m_type = playerType;
|
|
||||||
m_host = onHost;
|
|
||||||
m_manager = manager;
|
|
||||||
m_customData = 0;
|
|
||||||
if( pUID )
|
|
||||||
{
|
|
||||||
memcpy(&m_ISD.m_UID,pUID,sizeof(PlayerUID));
|
|
||||||
#ifdef __PSVITA__
|
#ifdef __PSVITA__
|
||||||
if(CGameNetworkManager::usingAdhocMode() && pUID->getOnlineID()[0] == 0)
|
if (CGameNetworkManager::usingAdhocMode() &&
|
||||||
{
|
pUID->getOnlineID()[0] == 0) {
|
||||||
assert(localPlayerIdx == 0);
|
assert(localPlayerIdx == 0);
|
||||||
// player doesn't have an online UID, set it from the player name
|
// player doesn't have an online UID, set it from the player name
|
||||||
m_ISD.m_UID.setForAdhoc();
|
m_ISD.m_UID.setForAdhoc();
|
||||||
}
|
}
|
||||||
#endif // __PSVITA__
|
#endif // __PSVITA__
|
||||||
}
|
} else {
|
||||||
else
|
memset(&m_ISD.m_UID, 0, sizeof(PlayerUID));
|
||||||
{
|
}
|
||||||
memset(&m_ISD.m_UID,0,sizeof(PlayerUID));
|
SetNameFromUID();
|
||||||
}
|
InitializeCriticalSection(&m_csQueue);
|
||||||
SetNameFromUID();
|
|
||||||
InitializeCriticalSection(&m_csQueue);
|
|
||||||
#ifdef __ORBIS__
|
#ifdef __ORBIS__
|
||||||
if(IsLocal())
|
if (IsLocal()) {
|
||||||
{
|
SonyVoiceChat_Orbis::initLocalPlayer(m_localPlayerIdx);
|
||||||
SonyVoiceChat_Orbis::initLocalPlayer(m_localPlayerIdx);
|
}
|
||||||
}
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
SQRNetworkPlayer::~SQRNetworkPlayer()
|
SQRNetworkPlayer::~SQRNetworkPlayer() {
|
||||||
{
|
|
||||||
#ifdef __ORBIS__
|
#ifdef __ORBIS__
|
||||||
SQRNetworkManager_Orbis* pMan = (SQRNetworkManager_Orbis*)m_manager;
|
SQRNetworkManager_Orbis* pMan = (SQRNetworkManager_Orbis*)m_manager;
|
||||||
// pMan->removePlayerFromVoiceChat(this);
|
// pMan->removePlayerFromVoiceChat(this);
|
||||||
// m_roomMemberId = -1;
|
// m_roomMemberId = -1;
|
||||||
#endif
|
#endif
|
||||||
DeleteCriticalSection(&m_csQueue);
|
DeleteCriticalSection(&m_csQueue);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool SQRNetworkPlayer::IsReady()
|
bool SQRNetworkPlayer::IsReady() {
|
||||||
{
|
return ((m_flags & SNP_FLAG_READY_MASK) == SNP_FLAG_READY_MASK);
|
||||||
return ( ( m_flags & SNP_FLAG_READY_MASK ) == SNP_FLAG_READY_MASK );
|
|
||||||
}
|
|
||||||
|
|
||||||
PlayerUID SQRNetworkPlayer::GetUID()
|
|
||||||
{
|
|
||||||
return m_ISD.m_UID;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void SQRNetworkPlayer::SetUID(PlayerUID UID)
|
PlayerUID SQRNetworkPlayer::GetUID() { return m_ISD.m_UID; }
|
||||||
{
|
|
||||||
m_ISD.m_UID = UID;
|
void SQRNetworkPlayer::SetUID(PlayerUID UID) {
|
||||||
SetNameFromUID();
|
m_ISD.m_UID = UID;
|
||||||
|
SetNameFromUID();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool SQRNetworkPlayer::HasConnectionAndSmallId()
|
bool SQRNetworkPlayer::HasConnectionAndSmallId() {
|
||||||
{
|
const int reqFlags =
|
||||||
const int reqFlags = ( SNP_FLAG_CONNECTION_COMPLETE | SNP_FLAG_SMALLID_ALLOCATED );
|
(SNP_FLAG_CONNECTION_COMPLETE | SNP_FLAG_SMALLID_ALLOCATED);
|
||||||
return (( m_flags & reqFlags) == reqFlags);
|
return ((m_flags & reqFlags) == reqFlags);
|
||||||
}
|
}
|
||||||
|
|
||||||
void SQRNetworkPlayer::ConnectionComplete()
|
void SQRNetworkPlayer::ConnectionComplete() {
|
||||||
{
|
m_host ? app.DebugPrintf(sc_verbose, "host : ")
|
||||||
m_host ? app.DebugPrintf(sc_verbose, "host : ") : app.DebugPrintf(sc_verbose, "client:");
|
: app.DebugPrintf(sc_verbose, "client:");
|
||||||
app.DebugPrintf(sc_verbose, ">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> ConnectionComplete\n");
|
app.DebugPrintf(sc_verbose,
|
||||||
m_flags |= SNP_FLAG_CONNECTION_COMPLETE;
|
">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>"
|
||||||
|
">> ConnectionComplete\n");
|
||||||
|
m_flags |= SNP_FLAG_CONNECTION_COMPLETE;
|
||||||
}
|
}
|
||||||
|
|
||||||
void SQRNetworkPlayer::SmallIdAllocated(unsigned char smallId)
|
void SQRNetworkPlayer::SmallIdAllocated(unsigned char smallId) {
|
||||||
{
|
m_ISD.m_smallId = smallId;
|
||||||
m_ISD.m_smallId = smallId;
|
m_flags |= SNP_FLAG_SMALLID_ALLOCATED;
|
||||||
m_flags |= SNP_FLAG_SMALLID_ALLOCATED;
|
m_host ? app.DebugPrintf(sc_verbose, "host : ")
|
||||||
m_host ? app.DebugPrintf(sc_verbose, "host : ") : app.DebugPrintf(sc_verbose, "client:");
|
: app.DebugPrintf(sc_verbose, "client:");
|
||||||
app.DebugPrintf(sc_verbose, ">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> Small ID allocated\n");
|
app.DebugPrintf(sc_verbose,
|
||||||
|
">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>"
|
||||||
|
">> Small ID allocated\n");
|
||||||
|
|
||||||
|
// If this is a non-network sort of player then flag now as having its small
|
||||||
|
// id confirmed
|
||||||
|
if ((m_type == SNP_TYPE_HOST) || (m_host && (m_type == SNP_TYPE_LOCAL)) ||
|
||||||
|
(!m_host && (m_type == SNP_TYPE_REMOTE))) {
|
||||||
|
m_host ? app.DebugPrintf(sc_verbose, "host : ")
|
||||||
|
: app.DebugPrintf(sc_verbose, "client:");
|
||||||
|
app.DebugPrintf(sc_verbose,
|
||||||
|
">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>"
|
||||||
|
">>>>>> Small ID confirmed\n");
|
||||||
|
|
||||||
// If this is a non-network sort of player then flag now as having its small id confirmed
|
m_flags |= SNP_FLAG_SMALLID_CONFIRMED;
|
||||||
if( ( m_type == SNP_TYPE_HOST ) ||
|
}
|
||||||
( m_host && ( m_type == SNP_TYPE_LOCAL ) ) ||
|
|
||||||
( !m_host && ( m_type == SNP_TYPE_REMOTE ) ) )
|
|
||||||
{
|
|
||||||
m_host ? app.DebugPrintf(sc_verbose, "host : ") : app.DebugPrintf(sc_verbose, "client:");
|
|
||||||
app.DebugPrintf(sc_verbose, ">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> Small ID confirmed\n");
|
|
||||||
|
|
||||||
m_flags |= SNP_FLAG_SMALLID_CONFIRMED;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void SQRNetworkPlayer::InitialDataReceived(SQRNetworkPlayer::InitSendData *ISD)
|
void SQRNetworkPlayer::InitialDataReceived(
|
||||||
{
|
SQRNetworkPlayer::InitSendData* ISD) {
|
||||||
assert(m_ISD.m_smallId == ISD->m_smallId);
|
assert(m_ISD.m_smallId == ISD->m_smallId);
|
||||||
memcpy(&m_ISD, ISD, sizeof(InitSendData) );
|
memcpy(&m_ISD, ISD, sizeof(InitSendData));
|
||||||
#ifdef __PSVITA__
|
#ifdef __PSVITA__
|
||||||
SetNameFromUID();
|
SetNameFromUID();
|
||||||
#endif
|
#endif
|
||||||
m_host ? app.DebugPrintf(sc_verbose, "host : ") : app.DebugPrintf(sc_verbose, "client:");
|
m_host ? app.DebugPrintf(sc_verbose, "host : ")
|
||||||
app.DebugPrintf(sc_verbose, ">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> Small ID confirmed\n");
|
: app.DebugPrintf(sc_verbose, "client:");
|
||||||
m_flags |= SNP_FLAG_SMALLID_CONFIRMED;
|
app.DebugPrintf(sc_verbose,
|
||||||
|
">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>"
|
||||||
|
">> Small ID confirmed\n");
|
||||||
|
m_flags |= SNP_FLAG_SMALLID_CONFIRMED;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool SQRNetworkPlayer::HasSmallIdConfirmed()
|
bool SQRNetworkPlayer::HasSmallIdConfirmed() {
|
||||||
{
|
return (m_flags & SNP_FLAG_SMALLID_CONFIRMED);
|
||||||
return ( m_flags & SNP_FLAG_SMALLID_CONFIRMED );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// To confirm to the host that we are ready, send a single byte with our small id.
|
// To confirm to the host that we are ready, send a single byte with our small
|
||||||
void SQRNetworkPlayer::ConfirmReady()
|
// id.
|
||||||
{
|
void SQRNetworkPlayer::ConfirmReady() {
|
||||||
#ifdef __PS3__
|
#ifdef __PS3__
|
||||||
int ret = cellRudpWrite( m_rudpCtx, &m_ISD, sizeof(InitSendData), CELL_RUDP_MSG_LATENCY_CRITICAL );
|
int ret = cellRudpWrite(m_rudpCtx, &m_ISD, sizeof(InitSendData),
|
||||||
#else //__ORBIS__
|
CELL_RUDP_MSG_LATENCY_CRITICAL);
|
||||||
int ret = sceRudpWrite( m_rudpCtx, &m_ISD, sizeof(InitSendData), SCE_RUDP_MSG_LATENCY_CRITICAL );
|
#else //__ORBIS__
|
||||||
|
int ret = sceRudpWrite(m_rudpCtx, &m_ISD, sizeof(InitSendData),
|
||||||
|
SCE_RUDP_MSG_LATENCY_CRITICAL);
|
||||||
#endif
|
#endif
|
||||||
// TODO - error handling here?
|
// TODO - error handling here?
|
||||||
assert ( ret == sizeof(InitSendData) );
|
assert(ret == sizeof(InitSendData));
|
||||||
// Final flag for a local player on the client, as we are now safe to send data on to the host
|
// Final flag for a local player on the client, as we are now safe to send
|
||||||
m_host ? app.DebugPrintf(sc_verbose, "host : ") : app.DebugPrintf(sc_verbose, "client:");
|
// data on to the host
|
||||||
app.DebugPrintf(sc_verbose, ">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> Small ID confirmed\n");
|
m_host ? app.DebugPrintf(sc_verbose, "host : ")
|
||||||
m_flags |= SNP_FLAG_SMALLID_CONFIRMED;
|
: app.DebugPrintf(sc_verbose, "client:");
|
||||||
|
app.DebugPrintf(sc_verbose,
|
||||||
|
">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>"
|
||||||
|
">> Small ID confirmed\n");
|
||||||
|
m_flags |= SNP_FLAG_SMALLID_CONFIRMED;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Attempt to send data, of any size, from this player to that specified by pPlayerTarget. This may not be possible depending on the two players, due to
|
// Attempt to send data, of any size, from this player to that specified by
|
||||||
// our star shaped network connectivity. Data may be any size, and is copied so on returning from this method it does not need to be preserved.
|
// pPlayerTarget. This may not be possible depending on the two players, due to
|
||||||
void SQRNetworkPlayer::SendData( SQRNetworkPlayer *pPlayerTarget, const void *data, unsigned int dataSize )
|
// our star shaped network connectivity. Data may be any size, and is copied so
|
||||||
{
|
// on returning from this method it does not need to be preserved.
|
||||||
// Our network is connected as a star. If we are the host, then we can send to any remote player. If we're a client, we can send only to the host.
|
void SQRNetworkPlayer::SendData(SQRNetworkPlayer* pPlayerTarget,
|
||||||
// The host can also send to other local players, but this doesn't need to go through Rudp.
|
const void* data, unsigned int dataSize) {
|
||||||
if( m_host )
|
// Our network is connected as a star. If we are the host, then we can send
|
||||||
{
|
// to any remote player. If we're a client, we can send only to the host.
|
||||||
if( ( m_type == SNP_TYPE_HOST ) && ( pPlayerTarget->m_type == SNP_TYPE_LOCAL ) )
|
// The host can also send to other local players, but this doesn't need to
|
||||||
{
|
// go through Rudp.
|
||||||
// Special internal communication from host to local player
|
if (m_host) {
|
||||||
m_manager->LocalDataSend( this, pPlayerTarget, data, dataSize );
|
if ((m_type == SNP_TYPE_HOST) &&
|
||||||
}
|
(pPlayerTarget->m_type == SNP_TYPE_LOCAL)) {
|
||||||
else if( ( m_type == SNP_TYPE_LOCAL ) && ( pPlayerTarget->m_type == SNP_TYPE_HOST ) )
|
// Special internal communication from host to local player
|
||||||
{
|
m_manager->LocalDataSend(this, pPlayerTarget, data, dataSize);
|
||||||
// Special internal communication from local player to host
|
} else if ((m_type == SNP_TYPE_LOCAL) &&
|
||||||
m_manager->LocalDataSend( this, pPlayerTarget, data, dataSize );
|
(pPlayerTarget->m_type == SNP_TYPE_HOST)) {
|
||||||
}
|
// Special internal communication from local player to host
|
||||||
else if( ( m_type == SNP_TYPE_HOST ) && ( pPlayerTarget->m_type == SNP_TYPE_REMOTE ) )
|
m_manager->LocalDataSend(this, pPlayerTarget, data, dataSize);
|
||||||
{
|
} else if ((m_type == SNP_TYPE_HOST) &&
|
||||||
// Rudp communication from host to remote player - handled by remote player instance
|
(pPlayerTarget->m_type == SNP_TYPE_REMOTE)) {
|
||||||
pPlayerTarget->SendInternal(data,dataSize);
|
// Rudp communication from host to remote player - handled by remote
|
||||||
}
|
// player instance
|
||||||
else
|
pPlayerTarget->SendInternal(data, dataSize);
|
||||||
{
|
} else {
|
||||||
// Can't do any other types of communications
|
// Can't do any other types of communications
|
||||||
assert(false);
|
assert(false);
|
||||||
}
|
}
|
||||||
}
|
} else {
|
||||||
else
|
if ((m_type == SNP_TYPE_LOCAL) &&
|
||||||
{
|
(pPlayerTarget->m_type == SNP_TYPE_HOST)) {
|
||||||
if( ( m_type == SNP_TYPE_LOCAL ) && ( pPlayerTarget->m_type == SNP_TYPE_HOST ) )
|
// Rudp communication from client to host - handled by this player
|
||||||
{
|
// instace
|
||||||
// Rudp communication from client to host - handled by this player instace
|
SendInternal(data, dataSize);
|
||||||
SendInternal(data, dataSize);
|
} else {
|
||||||
}
|
// Can't do any other types of communications
|
||||||
else
|
assert(false);
|
||||||
{
|
}
|
||||||
// Can't do any other types of communications
|
}
|
||||||
assert(false);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Internal send function - to simplify the number of mechanisms we have for sending data, this method just adds the data to be send to the player's internal queue,
|
// Internal send function - to simplify the number of mechanisms we have for
|
||||||
// and then calls SendMoreInternal. This method can take any size of data, which it will split up into payload size chunks before sending. All input data is copied
|
// sending data, this method just adds the data to be send to the player's
|
||||||
// into internal buffers.
|
// internal queue, and then calls SendMoreInternal. This method can take any
|
||||||
void SQRNetworkPlayer::SendInternal(const void *data, unsigned int dataSize)
|
// size of data, which it will split up into payload size chunks before sending.
|
||||||
{
|
// All input data is copied into internal buffers.
|
||||||
EnterCriticalSection(&m_csQueue);
|
void SQRNetworkPlayer::SendInternal(const void* data, unsigned int dataSize) {
|
||||||
|
EnterCriticalSection(&m_csQueue);
|
||||||
|
|
||||||
QueuedSendBlock sendBlock;
|
QueuedSendBlock sendBlock;
|
||||||
|
|
||||||
unsigned char *dataCurrent = (unsigned char *)data;
|
unsigned char* dataCurrent = (unsigned char*)data;
|
||||||
unsigned int dataRemaining = dataSize;
|
unsigned int dataRemaining = dataSize;
|
||||||
|
|
||||||
while( dataRemaining )
|
while (dataRemaining) {
|
||||||
{
|
int dataSize = dataRemaining;
|
||||||
int dataSize = dataRemaining;
|
if (dataSize > SNP_MAX_PAYLOAD) dataSize = SNP_MAX_PAYLOAD;
|
||||||
if( dataSize > SNP_MAX_PAYLOAD ) dataSize = SNP_MAX_PAYLOAD;
|
sendBlock.start = new unsigned char[dataSize];
|
||||||
sendBlock.start = new unsigned char [dataSize];
|
sendBlock.end = sendBlock.start + dataSize;
|
||||||
sendBlock.end = sendBlock.start + dataSize;
|
sendBlock.current = sendBlock.start;
|
||||||
sendBlock.current = sendBlock.start;
|
memcpy(sendBlock.start, dataCurrent, dataSize);
|
||||||
memcpy( sendBlock.start, dataCurrent, dataSize);
|
m_sendQueue.push(sendBlock);
|
||||||
m_sendQueue.push(sendBlock);
|
dataRemaining -= dataSize;
|
||||||
dataRemaining -= dataSize;
|
dataCurrent += dataSize;
|
||||||
dataCurrent += dataSize;
|
}
|
||||||
}
|
|
||||||
|
|
||||||
// Now try and send as much as we can
|
// Now try and send as much as we can
|
||||||
SendMoreInternal();
|
SendMoreInternal();
|
||||||
|
|
||||||
LeaveCriticalSection(&m_csQueue);
|
LeaveCriticalSection(&m_csQueue);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Internal send function. This attempts to send as many elements in the queue
|
||||||
|
// as possible until the write function tells us that we can't send any more.
|
||||||
|
// This way, we are guaranteed that if there *is* anything more in the queue
|
||||||
// Internal send function. This attempts to send as many elements in the queue as possible until the write function tells us that we can't send any more. This way,
|
// left to send, we'll get a CELL_RUDP_CONTEXT_EVENT_WRITABLE event when
|
||||||
// we are guaranteed that if there *is* anything more in the queue left to send, we'll get a CELL_RUDP_CONTEXT_EVENT_WRITABLE event when whatever we've managed to
|
// whatever we've managed to send here is complete, and can continue on.
|
||||||
// send here is complete, and can continue on.
|
void SQRNetworkPlayer::SendMoreInternal() {
|
||||||
void SQRNetworkPlayer::SendMoreInternal()
|
EnterCriticalSection(&m_csQueue);
|
||||||
{
|
bool keepSending;
|
||||||
EnterCriticalSection(&m_csQueue);
|
do {
|
||||||
bool keepSending;
|
keepSending = false;
|
||||||
do
|
if (m_sendQueue.size() > 0) {
|
||||||
{
|
// Attempt to send the full data in the first element in our queue
|
||||||
keepSending = false;
|
unsigned char* data = m_sendQueue.front().current;
|
||||||
if( m_sendQueue.size() > 0)
|
int dataSize =
|
||||||
{
|
m_sendQueue.front().end - m_sendQueue.front().current;
|
||||||
// Attempt to send the full data in the first element in our queue
|
|
||||||
unsigned char *data= m_sendQueue.front().current;
|
|
||||||
int dataSize = m_sendQueue.front().end - m_sendQueue.front().current;
|
|
||||||
#ifdef __PS3__
|
#ifdef __PS3__
|
||||||
int ret = cellRudpWrite( m_rudpCtx, data, dataSize, 0);//CELL_RUDP_MSG_LATENCY_CRITICAL );
|
int ret = cellRudpWrite(m_rudpCtx, data, dataSize,
|
||||||
int wouldBlockFlag = CELL_RUDP_ERROR_WOULDBLOCK;
|
0); // CELL_RUDP_MSG_LATENCY_CRITICAL );
|
||||||
|
int wouldBlockFlag = CELL_RUDP_ERROR_WOULDBLOCK;
|
||||||
|
|
||||||
#else // __ORBIS__
|
#else // __ORBIS__
|
||||||
int ret = sceRudpWrite( m_rudpCtx, data, dataSize, 0);//CELL_RUDP_MSG_LATENCY_CRITICAL );
|
int ret = sceRudpWrite(m_rudpCtx, data, dataSize,
|
||||||
int wouldBlockFlag = SCE_RUDP_ERROR_WOULDBLOCK;
|
0); // CELL_RUDP_MSG_LATENCY_CRITICAL );
|
||||||
|
int wouldBlockFlag = SCE_RUDP_ERROR_WOULDBLOCK;
|
||||||
#endif
|
#endif
|
||||||
if( ret == dataSize )
|
if (ret == dataSize) {
|
||||||
{
|
// Fully sent, remove from queue - will loop in the while loop
|
||||||
// Fully sent, remove from queue - will loop in the while loop to see if there's anything else in the queue we could send
|
// to see if there's anything else in the queue we could send
|
||||||
delete [] m_sendQueue.front().start;
|
delete[] m_sendQueue.front().start;
|
||||||
m_sendQueue.pop();
|
m_sendQueue.pop();
|
||||||
if( m_sendQueue.size() )
|
if (m_sendQueue.size()) {
|
||||||
{
|
keepSending = true;
|
||||||
keepSending = true;
|
}
|
||||||
}
|
} else if ((ret >= 0) || (ret == wouldBlockFlag)) {
|
||||||
}
|
// Things left to send - adjust this element in the queue
|
||||||
else if( ( ret >= 0 ) || ( ret == wouldBlockFlag ) )
|
int remainingBytes;
|
||||||
{
|
if (ret >= 0) {
|
||||||
|
// Only ret bytes sent so far
|
||||||
|
remainingBytes = dataSize - ret;
|
||||||
// Things left to send - adjust this element in the queue
|
assert(remainingBytes > 0);
|
||||||
int remainingBytes;
|
} else {
|
||||||
if( ret >= 0 )
|
// Is CELL_RUDP_ERROR_WOULDBLOCK, nothing has yet been sent
|
||||||
{
|
remainingBytes = dataSize;
|
||||||
// Only ret bytes sent so far
|
}
|
||||||
remainingBytes = dataSize - ret;
|
m_sendQueue.front().current =
|
||||||
assert(remainingBytes > 0 );
|
m_sendQueue.front().end - remainingBytes;
|
||||||
}
|
}
|
||||||
else
|
}
|
||||||
{
|
} while (keepSending);
|
||||||
// Is CELL_RUDP_ERROR_WOULDBLOCK, nothing has yet been sent
|
LeaveCriticalSection(&m_csQueue);
|
||||||
remainingBytes = dataSize;
|
|
||||||
}
|
|
||||||
m_sendQueue.front().current = m_sendQueue.front().end - remainingBytes;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} while (keepSending);
|
|
||||||
LeaveCriticalSection(&m_csQueue);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void SQRNetworkPlayer::SetNameFromUID()
|
void SQRNetworkPlayer::SetNameFromUID() {
|
||||||
{
|
mbstowcs(m_name, m_ISD.m_UID.getOnlineID(), 16);
|
||||||
mbstowcs(m_name, m_ISD.m_UID.getOnlineID(), 16);
|
m_name[16] = 0;
|
||||||
m_name[16] = 0;
|
#ifdef __PS3__ // only 1 player on vita, and they have to be online (or adhoc),
|
||||||
#ifdef __PS3__ // only 1 player on vita, and they have to be online (or adhoc), and with PS4 all local players need to be signed in
|
// and with PS4 all local players need to be signed in
|
||||||
// Not an online player? Add a suffix with the controller ID on
|
// Not an online player? Add a suffix with the controller ID on
|
||||||
if( m_ISD.m_UID.isSignedIntoPSN() == 0)
|
if (m_ISD.m_UID.isSignedIntoPSN() == 0) {
|
||||||
{
|
int pos = wcslen(m_name);
|
||||||
int pos = wcslen(m_name);
|
swprintf(&m_name[pos], 5, L" (%d)", m_ISD.m_UID.getQuadrant() + 1);
|
||||||
swprintf(&m_name[pos], 5, L" (%d)", m_ISD.m_UID.getQuadrant() + 1 );
|
}
|
||||||
}
|
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
void SQRNetworkPlayer::SetName(char *name)
|
void SQRNetworkPlayer::SetName(char* name) {
|
||||||
{
|
mbstowcs(m_name, name, 20);
|
||||||
mbstowcs(m_name, name, 20);
|
m_name[20] = 0;
|
||||||
m_name[20] = 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int SQRNetworkPlayer::GetSessionIndex()
|
int SQRNetworkPlayer::GetSessionIndex() {
|
||||||
{
|
return m_manager->GetSessionIndex(this);
|
||||||
return m_manager->GetSessionIndex(this);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool SQRNetworkPlayer::HasVoice()
|
bool SQRNetworkPlayer::HasVoice() {
|
||||||
{
|
|
||||||
#ifdef __ORBIS__
|
#ifdef __ORBIS__
|
||||||
return SonyVoiceChat_Orbis::hasMicConnected(this);
|
return SonyVoiceChat_Orbis::hasMicConnected(this);
|
||||||
#elif defined __PSVITA__
|
#elif defined __PSVITA__
|
||||||
return SonyVoiceChat_Vita::hasMicConnected(this);
|
return SonyVoiceChat_Vita::hasMicConnected(this);
|
||||||
#else
|
#else
|
||||||
return SonyVoiceChat::hasMicConnected(&m_roomMemberId);
|
return SonyVoiceChat::hasMicConnected(&m_roomMemberId);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
bool SQRNetworkPlayer::IsTalking()
|
bool SQRNetworkPlayer::IsTalking() {
|
||||||
{
|
|
||||||
#ifdef __ORBIS__
|
#ifdef __ORBIS__
|
||||||
return SonyVoiceChat_Orbis::isTalking(this);
|
return SonyVoiceChat_Orbis::isTalking(this);
|
||||||
#elif defined __PSVITA__
|
#elif defined __PSVITA__
|
||||||
return SonyVoiceChat_Vita::isTalking(this);
|
return SonyVoiceChat_Vita::isTalking(this);
|
||||||
#else
|
#else
|
||||||
return SonyVoiceChat::isTalking(&m_roomMemberId);
|
return SonyVoiceChat::isTalking(&m_roomMemberId);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
bool SQRNetworkPlayer::IsMutedByLocalUser(int userIndex)
|
bool SQRNetworkPlayer::IsMutedByLocalUser(int userIndex) {
|
||||||
{
|
|
||||||
#ifdef __ORBIS__
|
#ifdef __ORBIS__
|
||||||
// assert(0); // this is never called, so isn't implemented in the PS4 voice stuff at the moment
|
// assert(0); // this is never called, so isn't implemented in the PS4
|
||||||
return false;
|
// voice stuff at the moment
|
||||||
|
return false;
|
||||||
#elif defined __PSVITA__
|
#elif defined __PSVITA__
|
||||||
return false;// this is never called, so isn't implemented in the Vita voice stuff at the moment
|
return false; // this is never called, so isn't implemented in the Vita
|
||||||
|
// voice stuff at the moment
|
||||||
#else
|
#else
|
||||||
SQRNetworkManager_PS3* pMan = (SQRNetworkManager_PS3*)m_manager;
|
SQRNetworkManager_PS3* pMan = (SQRNetworkManager_PS3*)m_manager;
|
||||||
return SonyVoiceChat::isMutedPlayer(pMan->m_roomSyncData.players[userIndex].m_roomMemberId);
|
return SonyVoiceChat::isMutedPlayer(
|
||||||
|
pMan->m_roomSyncData.players[userIndex].m_roomMemberId);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -2,102 +2,139 @@
|
||||||
#include "SQRNetworkManager.h"
|
#include "SQRNetworkManager.h"
|
||||||
#include <queue>
|
#include <queue>
|
||||||
|
|
||||||
// This is the lowest level class for handling the concept of a player on Sony platforms. This is managed by SQRNetworkManager. The game shouldn't directly communicate
|
// This is the lowest level class for handling the concept of a player on Sony
|
||||||
// with this class, as it is wrapped by NetworkPlayerSony which is an implementation of a platform-independent interface INetworkPlayer.
|
// platforms. This is managed by SQRNetworkManager. The game shouldn't directly
|
||||||
|
// communicate with this class, as it is wrapped by NetworkPlayerSony which is
|
||||||
|
// an implementation of a platform-independent interface INetworkPlayer.
|
||||||
|
|
||||||
class SQRNetworkPlayer
|
class SQRNetworkPlayer {
|
||||||
{
|
|
||||||
#ifdef __ORBIS__
|
#ifdef __ORBIS__
|
||||||
friend class SQRNetworkManager_Orbis;
|
friend class SQRNetworkManager_Orbis;
|
||||||
friend class SonyVoiceChat_Orbis;
|
friend class SonyVoiceChat_Orbis;
|
||||||
#elif defined __PS3__
|
#elif defined __PS3__
|
||||||
friend class SQRNetworkManager_PS3;
|
friend class SQRNetworkManager_PS3;
|
||||||
#else // __PSVITA__
|
#else // __PSVITA__
|
||||||
friend class SQRNetworkManager_Vita;
|
friend class SQRNetworkManager_Vita;
|
||||||
friend class SQRNetworkManager_AdHoc_Vita;
|
friend class SQRNetworkManager_AdHoc_Vita;
|
||||||
friend class SonyVoiceChat_Vita;
|
friend class SonyVoiceChat_Vita;
|
||||||
#endif
|
#endif
|
||||||
friend class SQRNetworkManager;
|
friend class SQRNetworkManager;
|
||||||
friend class NetworkPlayerSony;
|
friend class NetworkPlayerSony;
|
||||||
friend class CPlatformNetworkManagerSony;
|
friend class CPlatformNetworkManagerSony;
|
||||||
|
|
||||||
int GetSmallId();
|
int GetSmallId();
|
||||||
wchar_t *GetName();
|
wchar_t* GetName();
|
||||||
bool IsRemote();
|
bool IsRemote();
|
||||||
bool IsHost();
|
bool IsHost();
|
||||||
bool IsLocal();
|
bool IsLocal();
|
||||||
int GetLocalPlayerIndex();
|
int GetLocalPlayerIndex();
|
||||||
bool IsSameSystem(SQRNetworkPlayer *other);
|
bool IsSameSystem(SQRNetworkPlayer* other);
|
||||||
uintptr_t GetCustomDataValue();
|
uintptr_t GetCustomDataValue();
|
||||||
void SetCustomDataValue(uintptr_t data);
|
void SetCustomDataValue(uintptr_t data);
|
||||||
bool HasVoice();
|
bool HasVoice();
|
||||||
bool IsTalking();
|
bool IsTalking();
|
||||||
bool IsMutedByLocalUser(int userIndex);
|
bool IsMutedByLocalUser(int userIndex);
|
||||||
|
|
||||||
static const int SNP_FLAG_CONNECTION_COMPLETE = 1; // This player has a fully connected Rudp or other local link established (to a remote player if this is on the host, to the host if this is a client) - or isn't expected to have one
|
static const int SNP_FLAG_CONNECTION_COMPLETE =
|
||||||
static const int SNP_FLAG_SMALLID_ALLOCATED = 2; // This player has a small id allocated
|
1; // This player has a fully connected Rudp or other local link
|
||||||
static const int SNP_FLAG_SMALLID_CONFIRMED = 4; // This player's small id has been confirmed as received by the client (only relevant for players using network communications, others set at the same time as allocating)
|
// established (to a remote player if this is on the host, to the
|
||||||
static const int SNP_FLAG_READY_MASK = 7; // Mask indicated all bits which must be set in the flags for this player to be considered "ready"
|
// host if this is a client) - or isn't expected to have one
|
||||||
|
static const int SNP_FLAG_SMALLID_ALLOCATED =
|
||||||
|
2; // This player has a small id allocated
|
||||||
|
static const int SNP_FLAG_SMALLID_CONFIRMED =
|
||||||
|
4; // This player's small id has been confirmed as received by the
|
||||||
|
// client (only relevant for players using network communications,
|
||||||
|
// others set at the same time as allocating)
|
||||||
|
static const int SNP_FLAG_READY_MASK =
|
||||||
|
7; // Mask indicated all bits which must be set in the flags for this
|
||||||
|
// player to be considered "ready"
|
||||||
|
|
||||||
static const int SNP_MAX_PAYLOAD = 1346; // This is the default RUDP payload size - if we want to change this we'll need to use cellRudpSetOption to set something else & adjust segment size
|
static const int SNP_MAX_PAYLOAD =
|
||||||
|
1346; // This is the default RUDP payload size - if we want to change
|
||||||
|
// this we'll need to use cellRudpSetOption to set something else
|
||||||
|
// & adjust segment size
|
||||||
|
|
||||||
typedef enum
|
typedef enum {
|
||||||
{
|
SNP_TYPE_HOST, // This player represents the host
|
||||||
SNP_TYPE_HOST, // This player represents the host
|
SNP_TYPE_LOCAL, // On host - this player is a local player that needs
|
||||||
SNP_TYPE_LOCAL, // On host - this player is a local player that needs communicated with specially not using rudp. On clients - this is a local player, where m_rudpCtx is the context used to communicate from this player to/from the host
|
// communicated with specially not using rudp. On
|
||||||
SNP_TYPE_REMOTE, // On host - this player's m_rupdCtx can be used to communicate from between the host and this player. On clients - this is a remote player that cannot be communicated with
|
// clients - this is a local player, where m_rudpCtx is
|
||||||
} eSQRNetworkPlayerType;
|
// the context used to communicate from this player
|
||||||
|
// to/from the host
|
||||||
|
SNP_TYPE_REMOTE, // On host - this player's m_rupdCtx can be used to
|
||||||
|
// communicate from between the host and this player.
|
||||||
|
// On clients - this is a remote player that cannot be
|
||||||
|
// communicated with
|
||||||
|
} eSQRNetworkPlayerType;
|
||||||
|
|
||||||
class QueuedSendBlock
|
class QueuedSendBlock {
|
||||||
{
|
public:
|
||||||
public:
|
unsigned char* start;
|
||||||
unsigned char *start;
|
unsigned char* end;
|
||||||
unsigned char *end;
|
unsigned char* current;
|
||||||
unsigned char *current;
|
};
|
||||||
};
|
|
||||||
|
|
||||||
class InitSendData
|
class InitSendData {
|
||||||
{
|
public:
|
||||||
public:
|
unsigned char
|
||||||
unsigned char m_smallId; // Id to uniquely and permanently identify this player between machines - assigned by the server
|
m_smallId; // Id to uniquely and permanently identify this player
|
||||||
PlayerUID m_UID;
|
// between machines - assigned by the server
|
||||||
};
|
PlayerUID m_UID;
|
||||||
|
};
|
||||||
|
|
||||||
SQRNetworkPlayer(SQRNetworkManager *manager, eSQRNetworkPlayerType playerType, bool onHost, SceNpMatching2RoomMemberId roomMemberId, int localPlayerIdx, int rudpCtx, PlayerUID *pUID);
|
SQRNetworkPlayer(SQRNetworkManager* manager,
|
||||||
~SQRNetworkPlayer();
|
eSQRNetworkPlayerType playerType, bool onHost,
|
||||||
|
SceNpMatching2RoomMemberId roomMemberId,
|
||||||
|
int localPlayerIdx, int rudpCtx, PlayerUID* pUID);
|
||||||
|
~SQRNetworkPlayer();
|
||||||
|
|
||||||
PlayerUID GetUID();
|
PlayerUID GetUID();
|
||||||
void SetUID(PlayerUID UID);
|
void SetUID(PlayerUID UID);
|
||||||
bool HasConnectionAndSmallId();
|
bool HasConnectionAndSmallId();
|
||||||
bool IsReady();
|
bool IsReady();
|
||||||
void ConnectionComplete();
|
void ConnectionComplete();
|
||||||
void SmallIdAllocated(unsigned char smallId);
|
void SmallIdAllocated(unsigned char smallId);
|
||||||
void InitialDataReceived(InitSendData *ISD); // Only for remote players as viewed from the host, this is set when the host has received confirmation that the client has received the small id for this player, ie it is now safe to send data to
|
void InitialDataReceived(
|
||||||
bool HasSmallIdConfirmed();
|
InitSendData*
|
||||||
|
ISD); // Only for remote players as viewed from the host, this is
|
||||||
|
// set when the host has received confirmation that the
|
||||||
|
// client has received the small id for this player, ie it is
|
||||||
|
// now safe to send data to
|
||||||
|
bool HasSmallIdConfirmed();
|
||||||
|
|
||||||
void SendData( SQRNetworkPlayer *pPlayerTarget, const void *data, unsigned int dataSize );
|
void SendData(SQRNetworkPlayer* pPlayerTarget, const void* data,
|
||||||
|
unsigned int dataSize);
|
||||||
|
|
||||||
void ConfirmReady();
|
void ConfirmReady();
|
||||||
void SendInternal(const void *data, unsigned int dataSize);
|
void SendInternal(const void* data, unsigned int dataSize);
|
||||||
void SendMoreInternal();
|
void SendMoreInternal();
|
||||||
#ifdef __PSVITA__
|
#ifdef __PSVITA__
|
||||||
void SendInternal_VitaAdhoc(const void *data, unsigned int dataSize, EAdhocDataTag tag = e_dataTag_Normal);
|
void SendInternal_VitaAdhoc(const void* data, unsigned int dataSize,
|
||||||
void SendMoreInternal_VitaAdhoc();
|
EAdhocDataTag tag = e_dataTag_Normal);
|
||||||
|
void SendMoreInternal_VitaAdhoc();
|
||||||
#endif
|
#endif
|
||||||
void SetNameFromUID();
|
void SetNameFromUID();
|
||||||
void SetName(char *name);
|
void SetName(char* name);
|
||||||
int GetSessionIndex();
|
int GetSessionIndex();
|
||||||
|
|
||||||
eSQRNetworkPlayerType m_type; // The player type
|
eSQRNetworkPlayerType m_type; // The player type
|
||||||
bool m_host; // Whether this actual player class is stored on a host (not whether it represents the host, or a player on the host machine)
|
bool m_host; // Whether this actual player class is stored on a host (not
|
||||||
int m_flags; // Flags reflecting current state of this player
|
// whether it represents the host, or a player on the host
|
||||||
int m_rudpCtx; // Rudp context that can be used to communicate between this player & the host (see comments for eSQRNetworkPlayerType above)
|
// machine)
|
||||||
int m_localPlayerIdx; // Index of this player on the machine to which it belongs
|
int m_flags; // Flags reflecting current state of this player
|
||||||
SceNpMatching2RoomMemberId m_roomMemberId; // The room member id, effectively a per machine id
|
int m_rudpCtx; // Rudp context that can be used to communicate between this
|
||||||
InitSendData m_ISD; // Player UID & ID that get sent together to the host when connection is established
|
// player & the host (see comments for eSQRNetworkPlayerType
|
||||||
SQRNetworkManager *m_manager; // Pointer back to the manager that is managing this player
|
// above)
|
||||||
wchar_t m_name[21];
|
int m_localPlayerIdx; // Index of this player on the machine to which it
|
||||||
uintptr_t m_customData;
|
// belongs
|
||||||
CRITICAL_SECTION m_csQueue;
|
SceNpMatching2RoomMemberId
|
||||||
std::queue<QueuedSendBlock> m_sendQueue;
|
m_roomMemberId; // The room member id, effectively a per machine id
|
||||||
|
InitSendData m_ISD; // Player UID & ID that get sent together to the host
|
||||||
|
// when connection is established
|
||||||
|
SQRNetworkManager*
|
||||||
|
m_manager; // Pointer back to the manager that is managing this player
|
||||||
|
wchar_t m_name[21];
|
||||||
|
uintptr_t m_customData;
|
||||||
|
CRITICAL_SECTION m_csQueue;
|
||||||
|
std::queue<QueuedSendBlock> m_sendQueue;
|
||||||
};
|
};
|
||||||
|
|
|
||||||
File diff suppressed because it is too large
Load diff
|
|
@ -10,164 +10,257 @@
|
||||||
#elif defined __PSVITA__
|
#elif defined __PSVITA__
|
||||||
#include <np.h>
|
#include <np.h>
|
||||||
#include <np_toolkit.h>
|
#include <np_toolkit.h>
|
||||||
#else // __ORBIS__
|
#else // __ORBIS__
|
||||||
|
|
||||||
#define SCE_NP_COMMERCE2_CATEGORY_ID_LEN SCE_TOOLKIT_NP_COMMERCE_CATEGORY_ID_LEN ///< The size of the category ID.
|
#define SCE_NP_COMMERCE2_CATEGORY_ID_LEN \
|
||||||
#define SCE_NP_COMMERCE2_PRODUCT_ID_LEN SCE_TOOLKIT_NP_COMMERCE_PRODUCT_ID_LEN ///< The size of the product ID.
|
SCE_TOOLKIT_NP_COMMERCE_CATEGORY_ID_LEN ///< The size of the category ID.
|
||||||
#define SCE_NP_COMMERCE2_CATEGORY_NAME_LEN SCE_TOOLKIT_NP_COMMERCE_CATEGORY_NAME_LEN ///< The size of the category name.
|
#define SCE_NP_COMMERCE2_PRODUCT_ID_LEN \
|
||||||
#define SCE_NP_COMMERCE2_CATEGORY_DESCRIPTION_LEN SCE_TOOLKIT_NP_COMMERCE_CATEGORY_DESCRIPTION_LEN ///< The size of the category description.
|
SCE_TOOLKIT_NP_COMMERCE_PRODUCT_ID_LEN ///< The size of the product ID.
|
||||||
#define SCE_NP_COMMERCE2_URL_LEN SCE_TOOLKIT_NP_COMMERCE_URL_LEN ///< The size of the URL.
|
#define SCE_NP_COMMERCE2_CATEGORY_NAME_LEN \
|
||||||
#define SCE_NP_COMMERCE2_PRODUCT_NAME_LEN SCE_TOOLKIT_NP_COMMERCE_PRODUCT_NAME_LEN ///< The size of the product name.
|
SCE_TOOLKIT_NP_COMMERCE_CATEGORY_NAME_LEN ///< The size of the category
|
||||||
#define SCE_NP_COMMERCE2_PRODUCT_SHORT_DESCRIPTION_LEN SCE_TOOLKIT_NP_COMMERCE_PRODUCT_SHORT_DESCRIPTION_LEN ///< The size of the product short description.
|
///< name.
|
||||||
#define SCE_NP_COMMERCE2_SP_NAME_LEN SCE_TOOLKIT_NP_COMMERCE_SP_NAME_LEN ///< The size of the licensee (publisher) name.
|
#define SCE_NP_COMMERCE2_CATEGORY_DESCRIPTION_LEN \
|
||||||
#define SCE_NP_COMMERCE2_CURRENCY_CODE_LEN SCE_TOOLKIT_NP_COMMERCE_CURRENCY_CODE_LEN ///< The size of currency code.
|
SCE_TOOLKIT_NP_COMMERCE_CATEGORY_DESCRIPTION_LEN ///< The size of the
|
||||||
#define SCE_NP_COMMERCE2_CURRENCY_CODE_LEN SCE_TOOLKIT_NP_COMMERCE_CURRENCY_CODE_LEN
|
///< category description.
|
||||||
#define SCE_NP_COMMERCE2_CURRENCY_SYMBOL_LEN SCE_TOOLKIT_NP_COMMERCE_CURRENCY_SYMBOL_LEN ///< The size of currency symbol.
|
#define SCE_NP_COMMERCE2_URL_LEN \
|
||||||
#define SCE_NP_COMMERCE2_THOUSAND_SEPARATOR_LEN SCE_TOOLKIT_NP_COMMERCE_THOUSAND_SEPARATOR_LEN ///< The size of the character separating every 3 digits of the price.
|
SCE_TOOLKIT_NP_COMMERCE_URL_LEN ///< The size of the URL.
|
||||||
#define SCE_NP_COMMERCE2_DECIMAL_LETTER_LEN SCE_TOOLKIT_NP_COMMERCE_DECIMAL_LETTER_LEN ///< The size of the character indicating the decimal point in the price.
|
#define SCE_NP_COMMERCE2_PRODUCT_NAME_LEN \
|
||||||
#define SCE_NP_COMMERCE2_SKU_ID_LEN SCE_TOOLKIT_NP_COMMERCE_SKU_ID_LEN ///< The size of the SKU ID.
|
SCE_TOOLKIT_NP_COMMERCE_PRODUCT_NAME_LEN ///< The size of the product name.
|
||||||
#define SCE_NP_COMMERCE2_PRODUCT_LONG_DESCRIPTION_LEN SCE_TOOLKIT_NP_COMMERCE_PRODUCT_LONG_DESCRIPTION_LEN ///< The size of the product long description.
|
#define SCE_NP_COMMERCE2_PRODUCT_SHORT_DESCRIPTION_LEN \
|
||||||
#define SCE_NP_COMMERCE2_PRODUCT_LEGAL_DESCRIPTION_LEN SCE_TOOLKIT_NP_COMMERCE_PRODUCT_LEGAL_DESCRIPTION_LEN ///< The size of the product legal description.
|
SCE_TOOLKIT_NP_COMMERCE_PRODUCT_SHORT_DESCRIPTION_LEN ///< The size of the
|
||||||
#define SCE_NP_COMMERCE2_RATING_SYSTEM_ID_LEN SCE_TOOLKIT_NP_COMMERCE_RATING_SYSTEM_ID_LEN ///< The size of the rating system ID.
|
///< product short
|
||||||
#define SCE_NP_ENTITLEMENT_ID_SIZE SCE_TOOLKIT_NP_COMMERCE_ENTITLEMENT_ID_LEN ///< The size of entitlement ID.
|
///< description.
|
||||||
|
#define SCE_NP_COMMERCE2_SP_NAME_LEN \
|
||||||
|
SCE_TOOLKIT_NP_COMMERCE_SP_NAME_LEN ///< The size of the licensee
|
||||||
|
///< (publisher) name.
|
||||||
|
#define SCE_NP_COMMERCE2_CURRENCY_CODE_LEN \
|
||||||
|
SCE_TOOLKIT_NP_COMMERCE_CURRENCY_CODE_LEN ///< The size of currency code.
|
||||||
|
#define SCE_NP_COMMERCE2_CURRENCY_CODE_LEN \
|
||||||
|
SCE_TOOLKIT_NP_COMMERCE_CURRENCY_CODE_LEN
|
||||||
|
#define SCE_NP_COMMERCE2_CURRENCY_SYMBOL_LEN \
|
||||||
|
SCE_TOOLKIT_NP_COMMERCE_CURRENCY_SYMBOL_LEN ///< The size of currency
|
||||||
|
///< symbol.
|
||||||
|
#define SCE_NP_COMMERCE2_THOUSAND_SEPARATOR_LEN \
|
||||||
|
SCE_TOOLKIT_NP_COMMERCE_THOUSAND_SEPARATOR_LEN ///< The size of the
|
||||||
|
///< character separating
|
||||||
|
///< every 3 digits of the
|
||||||
|
///< price.
|
||||||
|
#define SCE_NP_COMMERCE2_DECIMAL_LETTER_LEN \
|
||||||
|
SCE_TOOLKIT_NP_COMMERCE_DECIMAL_LETTER_LEN ///< The size of the character
|
||||||
|
///< indicating the decimal
|
||||||
|
///< point in the price.
|
||||||
|
#define SCE_NP_COMMERCE2_SKU_ID_LEN \
|
||||||
|
SCE_TOOLKIT_NP_COMMERCE_SKU_ID_LEN ///< The size of the SKU ID.
|
||||||
|
#define SCE_NP_COMMERCE2_PRODUCT_LONG_DESCRIPTION_LEN \
|
||||||
|
SCE_TOOLKIT_NP_COMMERCE_PRODUCT_LONG_DESCRIPTION_LEN ///< The size of the
|
||||||
|
///< product long
|
||||||
|
///< description.
|
||||||
|
#define SCE_NP_COMMERCE2_PRODUCT_LEGAL_DESCRIPTION_LEN \
|
||||||
|
SCE_TOOLKIT_NP_COMMERCE_PRODUCT_LEGAL_DESCRIPTION_LEN ///< The size of the
|
||||||
|
///< product legal
|
||||||
|
///< description.
|
||||||
|
#define SCE_NP_COMMERCE2_RATING_SYSTEM_ID_LEN \
|
||||||
|
SCE_TOOLKIT_NP_COMMERCE_RATING_SYSTEM_ID_LEN ///< The size of the rating
|
||||||
|
///< system ID.
|
||||||
|
#define SCE_NP_ENTITLEMENT_ID_SIZE \
|
||||||
|
SCE_TOOLKIT_NP_COMMERCE_ENTITLEMENT_ID_LEN ///< The size of entitlement ID.
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifndef __PSVITA__
|
#ifndef __PSVITA__
|
||||||
#define SCE_TOOLKIT_NP_SKU_PRICE_LEN (SCE_NP_COMMERCE2_CURRENCY_CODE_LEN \
|
#define SCE_TOOLKIT_NP_SKU_PRICE_LEN \
|
||||||
+ SCE_NP_COMMERCE2_CURRENCY_SYMBOL_LEN \
|
(SCE_NP_COMMERCE2_CURRENCY_CODE_LEN + \
|
||||||
+ SCE_NP_COMMERCE2_THOUSAND_SEPARATOR_LEN \
|
SCE_NP_COMMERCE2_CURRENCY_SYMBOL_LEN + \
|
||||||
+ SCE_NP_COMMERCE2_DECIMAL_LETTER_LEN) ///< The maximum length of a price in characters.
|
SCE_NP_COMMERCE2_THOUSAND_SEPARATOR_LEN + \
|
||||||
|
SCE_NP_COMMERCE2_DECIMAL_LETTER_LEN) ///< The maximum length of a price in
|
||||||
|
///< characters.
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
class SonyCommerce
|
class SonyCommerce {
|
||||||
{
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
typedef void (*CallbackFunc)(void* lpParam, int error_code);
|
typedef void (*CallbackFunc)(void* lpParam, int error_code);
|
||||||
|
|
||||||
|
/// @brief
|
||||||
|
/// Contains information about a subcategory on the PlayStation(R)Store.
|
||||||
|
///
|
||||||
|
/// Contains information about a subcategory on the PlayStation(R)Store.
|
||||||
|
typedef struct CategoryInfoSub {
|
||||||
|
char categoryId[SCE_NP_COMMERCE2_CATEGORY_ID_LEN]; ///< The ID of the
|
||||||
|
///< subcategory.
|
||||||
|
char
|
||||||
|
categoryName[SCE_NP_COMMERCE2_CATEGORY_NAME_LEN]; ///< The name of
|
||||||
|
///< the
|
||||||
|
///< subcategory.
|
||||||
|
char categoryDescription
|
||||||
|
[SCE_NP_COMMERCE2_CATEGORY_DESCRIPTION_LEN]; ///< The detailed
|
||||||
|
///< description of
|
||||||
|
///< the subcategory.
|
||||||
|
char imageUrl[SCE_NP_COMMERCE2_URL_LEN]; ///< The image URL of the
|
||||||
|
///< subcategory.
|
||||||
|
} CategoryInfoSub;
|
||||||
|
|
||||||
/// @brief
|
/// @brief
|
||||||
/// Contains information about a subcategory on the PlayStation(R)Store.
|
/// Current category information
|
||||||
///
|
///
|
||||||
/// Contains information about a subcategory on the PlayStation(R)Store.
|
/// This structure contains information about a category on the
|
||||||
typedef struct CategoryInfoSub
|
/// PlayStation(R)Store
|
||||||
{
|
typedef struct CategoryInfo {
|
||||||
char categoryId[SCE_NP_COMMERCE2_CATEGORY_ID_LEN]; ///< The ID of the subcategory.
|
CategoryInfoSub current; ///< The currently selected subcategory.
|
||||||
char categoryName[SCE_NP_COMMERCE2_CATEGORY_NAME_LEN]; ///< The name of the subcategory.
|
std::list<CategoryInfoSub>
|
||||||
char categoryDescription[SCE_NP_COMMERCE2_CATEGORY_DESCRIPTION_LEN]; ///< The detailed description of the subcategory.
|
subCategories; ///< Information about the subcategories in this
|
||||||
char imageUrl[SCE_NP_COMMERCE2_URL_LEN]; ///< The image URL of the subcategory.
|
///< category.
|
||||||
}
|
uint32_t countOfProducts; ///< The number of products in the category.
|
||||||
CategoryInfoSub;
|
uint32_t countOfSubCategories; ///< The number of subcategories.
|
||||||
|
} CategoryInfo;
|
||||||
|
|
||||||
/// @brief
|
/// Contains information about a product in the PlayStation(R)Store.
|
||||||
/// Current category information
|
typedef struct ProductInfo {
|
||||||
///
|
uint32_t
|
||||||
/// This structure contains information about a category on the PlayStation(R)Store
|
purchasabilityFlag; ///< A flag that indicates whether the product
|
||||||
typedef struct CategoryInfo
|
///< can be purchased
|
||||||
{
|
///< (<c>SCE_NP_COMMERCE2_SKU_PURCHASABILITY_FLAG_XXX</c>).
|
||||||
CategoryInfoSub current; ///< The currently selected subcategory.
|
uint32_t
|
||||||
std::list<CategoryInfoSub> subCategories; ///< Information about the subcategories in this category.
|
annotation; // SCE_NP_COMMERCE2_SKU_ANN_PURCHASED_CANNOT_PURCHASE_AGAIN
|
||||||
uint32_t countOfProducts; ///< The number of products in the category.
|
// or
|
||||||
uint32_t countOfSubCategories; ///< The number of subcategories.
|
// SCE_NP_COMMERCE2_SKU_ANN_PURCHASED_CAN_PURCHASE_AGAIN
|
||||||
}
|
uint32_t ui32Price;
|
||||||
CategoryInfo;
|
char productId[SCE_NP_COMMERCE2_PRODUCT_ID_LEN]; ///< The product ID.
|
||||||
|
char productName[SCE_NP_COMMERCE2_PRODUCT_NAME_LEN]; ///< The name of
|
||||||
/// Contains information about a product in the PlayStation(R)Store.
|
///< the product.
|
||||||
typedef struct ProductInfo
|
char shortDescription
|
||||||
{
|
[SCE_NP_COMMERCE2_PRODUCT_SHORT_DESCRIPTION_LEN]; ///< A short
|
||||||
uint32_t purchasabilityFlag; ///< A flag that indicates whether the product can be purchased (<c>SCE_NP_COMMERCE2_SKU_PURCHASABILITY_FLAG_XXX</c>).
|
///< description
|
||||||
uint32_t annotation; // SCE_NP_COMMERCE2_SKU_ANN_PURCHASED_CANNOT_PURCHASE_AGAIN or SCE_NP_COMMERCE2_SKU_ANN_PURCHASED_CAN_PURCHASE_AGAIN
|
///< of the
|
||||||
uint32_t ui32Price;
|
///< product.
|
||||||
char productId[SCE_NP_COMMERCE2_PRODUCT_ID_LEN]; ///< The product ID.
|
char longDescription
|
||||||
char productName[SCE_NP_COMMERCE2_PRODUCT_NAME_LEN]; ///< The name of the product.
|
[SCE_NP_COMMERCE2_PRODUCT_LONG_DESCRIPTION_LEN]; ///< A long
|
||||||
char shortDescription[SCE_NP_COMMERCE2_PRODUCT_SHORT_DESCRIPTION_LEN]; ///< A short description of the product.
|
///< description
|
||||||
char longDescription[SCE_NP_COMMERCE2_PRODUCT_LONG_DESCRIPTION_LEN]; ///< A long description of the product.
|
///< of the
|
||||||
char skuId[SCE_NP_COMMERCE2_SKU_ID_LEN]; ///< The SKU ID
|
///< product.
|
||||||
char spName[SCE_NP_COMMERCE2_SP_NAME_LEN]; ///< The service provider name.
|
char skuId[SCE_NP_COMMERCE2_SKU_ID_LEN]; ///< The SKU ID
|
||||||
char imageUrl[SCE_NP_COMMERCE2_URL_LEN]; ///< The product image URL.
|
char spName[SCE_NP_COMMERCE2_SP_NAME_LEN]; ///< The service provider
|
||||||
char price[SCE_TOOLKIT_NP_SKU_PRICE_LEN]; ///< The price of the product. This is formatted to include the currency code.
|
///< name.
|
||||||
char padding[6]; ///< Padding.
|
char imageUrl[SCE_NP_COMMERCE2_URL_LEN]; ///< The product image URL.
|
||||||
|
char price[SCE_TOOLKIT_NP_SKU_PRICE_LEN]; ///< The price of the
|
||||||
|
///< product. This is
|
||||||
|
///< formatted to include the
|
||||||
|
///< currency code.
|
||||||
|
char padding[6]; ///< Padding.
|
||||||
#ifdef __PS3__
|
#ifdef __PS3__
|
||||||
CellRtcTick releaseDate; ///< The product release date.
|
CellRtcTick releaseDate; ///< The product release date.
|
||||||
#else
|
#else
|
||||||
SceRtcTick releaseDate;
|
SceRtcTick releaseDate;
|
||||||
#endif
|
#endif
|
||||||
}
|
} ProductInfo;
|
||||||
ProductInfo;
|
|
||||||
|
|
||||||
/// @brief
|
/// @brief
|
||||||
/// Contains detailed information about a product on the PlayStation(R)Store.
|
/// Contains detailed information about a product on the
|
||||||
///
|
/// PlayStation(R)Store.
|
||||||
/// Contains detailed information about a product on the PlayStation(R)Store.
|
///
|
||||||
typedef struct ProductInfoDetailed
|
/// Contains detailed information about a product on the
|
||||||
{
|
/// PlayStation(R)Store.
|
||||||
uint32_t purchasabilityFlag; ///< A flag that indicates whether the product can be purchased (<c>SCE_NP_COMMERCE2_SKU_PURCHASABILITY_FLAG_XXX</c>).
|
typedef struct ProductInfoDetailed {
|
||||||
uint32_t ui32Price;
|
uint32_t
|
||||||
char skuId[SCE_NP_COMMERCE2_SKU_ID_LEN]; ///< The SKU ID
|
purchasabilityFlag; ///< A flag that indicates whether the product
|
||||||
char productId[SCE_NP_COMMERCE2_PRODUCT_ID_LEN]; ///< The product ID.
|
///< can be purchased
|
||||||
char productName[SCE_NP_COMMERCE2_PRODUCT_NAME_LEN]; ///< The name of the product.
|
///< (<c>SCE_NP_COMMERCE2_SKU_PURCHASABILITY_FLAG_XXX</c>).
|
||||||
char shortDescription[SCE_NP_COMMERCE2_PRODUCT_SHORT_DESCRIPTION_LEN]; ///< A short description of the product.
|
uint32_t ui32Price;
|
||||||
char longDescription[SCE_NP_COMMERCE2_PRODUCT_LONG_DESCRIPTION_LEN]; ///< A long description of the product.
|
char skuId[SCE_NP_COMMERCE2_SKU_ID_LEN]; ///< The SKU ID
|
||||||
char legalDescription[SCE_NP_COMMERCE2_PRODUCT_LEGAL_DESCRIPTION_LEN]; ///< The legal description for the product.
|
char productId[SCE_NP_COMMERCE2_PRODUCT_ID_LEN]; ///< The product ID.
|
||||||
char spName[SCE_NP_COMMERCE2_SP_NAME_LEN]; ///< The service provider name.
|
char productName[SCE_NP_COMMERCE2_PRODUCT_NAME_LEN]; ///< The name of
|
||||||
char imageUrl[SCE_NP_COMMERCE2_URL_LEN]; ///< The product image URL.
|
///< the product.
|
||||||
char price[SCE_TOOLKIT_NP_SKU_PRICE_LEN]; ///< The price of the product. This is formatted to include the currency code.
|
char shortDescription
|
||||||
char ratingSystemId[SCE_NP_COMMERCE2_RATING_SYSTEM_ID_LEN]; ///< The ID of the rating system (for example: PEGI, ESRB).
|
[SCE_NP_COMMERCE2_PRODUCT_SHORT_DESCRIPTION_LEN]; ///< A short
|
||||||
char ratingImageUrl[SCE_NP_COMMERCE2_URL_LEN]; ///< The URL of the rating icon.
|
///< description
|
||||||
char padding[2]; ///< Padding.
|
///< of the
|
||||||
|
///< product.
|
||||||
|
char longDescription
|
||||||
|
[SCE_NP_COMMERCE2_PRODUCT_LONG_DESCRIPTION_LEN]; ///< A long
|
||||||
|
///< description
|
||||||
|
///< of the
|
||||||
|
///< product.
|
||||||
|
char legalDescription
|
||||||
|
[SCE_NP_COMMERCE2_PRODUCT_LEGAL_DESCRIPTION_LEN]; ///< The legal
|
||||||
|
///< description
|
||||||
|
///< for the
|
||||||
|
///< product.
|
||||||
|
char spName[SCE_NP_COMMERCE2_SP_NAME_LEN]; ///< The service provider
|
||||||
|
///< name.
|
||||||
|
char imageUrl[SCE_NP_COMMERCE2_URL_LEN]; ///< The product image URL.
|
||||||
|
char price[SCE_TOOLKIT_NP_SKU_PRICE_LEN]; ///< The price of the
|
||||||
|
///< product. This is
|
||||||
|
///< formatted to include the
|
||||||
|
///< currency code.
|
||||||
|
char ratingSystemId
|
||||||
|
[SCE_NP_COMMERCE2_RATING_SYSTEM_ID_LEN]; ///< The ID of the rating
|
||||||
|
///< system (for example:
|
||||||
|
///< PEGI, ESRB).
|
||||||
|
char ratingImageUrl[SCE_NP_COMMERCE2_URL_LEN]; ///< The URL of the
|
||||||
|
///< rating icon.
|
||||||
|
char padding[2]; ///< Padding.
|
||||||
#ifdef __PS3__
|
#ifdef __PS3__
|
||||||
std::list<SceNpCommerce2ContentRatingDescriptor> ratingDescriptors; ///< The list of rating descriptors.
|
std::list<SceNpCommerce2ContentRatingDescriptor>
|
||||||
CellRtcTick releaseDate; ///< The product release date.
|
ratingDescriptors; ///< The list of rating descriptors.
|
||||||
#else
|
CellRtcTick releaseDate; ///< The product release date.
|
||||||
SceRtcTick releaseDate; ///< The product release date.
|
#else
|
||||||
|
SceRtcTick releaseDate; ///< The product release date.
|
||||||
#endif
|
#endif
|
||||||
}
|
} ProductInfoDetailed;
|
||||||
ProductInfoDetailed;
|
|
||||||
|
|
||||||
/// @brief
|
/// @brief
|
||||||
/// Checkout parameters
|
/// Checkout parameters
|
||||||
///
|
///
|
||||||
/// This structure contains list of SKUs to checkout to and a memory container
|
/// This structure contains list of SKUs to checkout to and a memory
|
||||||
typedef struct CheckoutInputParams
|
/// container
|
||||||
{
|
typedef struct CheckoutInputParams {
|
||||||
std::list<const char *> skuIds; ///< List of SKU IDs
|
std::list<const char*> skuIds; ///< List of SKU IDs
|
||||||
#ifdef __PS3__
|
#ifdef __PS3__
|
||||||
sys_memory_container_t *memContainer; ///< Memory container for checkout overlay
|
sys_memory_container_t*
|
||||||
|
memContainer; ///< Memory container for checkout overlay
|
||||||
#endif
|
#endif
|
||||||
}
|
} CheckoutInputParams;
|
||||||
CheckoutInputParams;
|
|
||||||
|
|
||||||
/// @brief
|
/// @brief
|
||||||
/// Contains download list parameters.
|
/// Contains download list parameters.
|
||||||
///
|
///
|
||||||
/// Contains download list parameters.
|
/// Contains download list parameters.
|
||||||
typedef struct DownloadListInputParams
|
typedef struct DownloadListInputParams {
|
||||||
{
|
std::list<const char*> skuIds; ///< The list of SKU IDs
|
||||||
std::list<const char *> skuIds; ///< The list of SKU IDs
|
|
||||||
#ifdef __PS3__
|
#ifdef __PS3__
|
||||||
sys_memory_container_t *memContainer; ///< A memory container for checkout overlay.
|
sys_memory_container_t*
|
||||||
|
memContainer; ///< A memory container for checkout overlay.
|
||||||
#endif
|
#endif
|
||||||
const char* categoryID;
|
const char* categoryID;
|
||||||
}
|
} DownloadListInputParams;
|
||||||
DownloadListInputParams;
|
|
||||||
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
virtual void CreateSession(CallbackFunc cb, void* lpParam) = 0;
|
virtual void CreateSession(CallbackFunc cb, void* lpParam) = 0;
|
||||||
virtual void CloseSession() = 0;
|
virtual void CloseSession() = 0;
|
||||||
|
|
||||||
virtual void GetCategoryInfo(CallbackFunc cb, void* lpParam, CategoryInfo *info, const char *categoryId) = 0;
|
virtual void GetCategoryInfo(CallbackFunc cb, void* lpParam,
|
||||||
virtual void GetProductList(CallbackFunc cb, void* lpParam, std::vector<ProductInfo>* productList, const char *categoryId) = 0;
|
CategoryInfo* info,
|
||||||
virtual void GetDetailedProductInfo(CallbackFunc cb, void* lpParam, ProductInfoDetailed* productInfoDetailed, const char *productId, const char *categoryId) = 0;
|
const char* categoryId) = 0;
|
||||||
virtual void AddDetailedProductInfo( CallbackFunc cb, void* lpParam, ProductInfo* productInfo, const char *productId, const char *categoryId ) = 0;
|
virtual void GetProductList(CallbackFunc cb, void* lpParam,
|
||||||
virtual void Checkout(CallbackFunc cb, void* lpParam, const char* skuID) = 0;
|
std::vector<ProductInfo>* productList,
|
||||||
virtual void DownloadAlreadyPurchased(CallbackFunc cb, void* lpParam, const char* skuID) = 0;
|
const char* categoryId) = 0;
|
||||||
#if defined(__ORBIS__) || defined( __PSVITA__)
|
virtual void GetDetailedProductInfo(
|
||||||
virtual void Checkout_Game(CallbackFunc cb, void* lpParam, const char* skuID) = 0;
|
CallbackFunc cb, void* lpParam,
|
||||||
virtual void DownloadAlreadyPurchased_Game(CallbackFunc cb, void* lpParam, const char* skuID) = 0;
|
ProductInfoDetailed* productInfoDetailed, const char* productId,
|
||||||
|
const char* categoryId) = 0;
|
||||||
|
virtual void AddDetailedProductInfo(CallbackFunc cb, void* lpParam,
|
||||||
|
ProductInfo* productInfo,
|
||||||
|
const char* productId,
|
||||||
|
const char* categoryId) = 0;
|
||||||
|
virtual void Checkout(CallbackFunc cb, void* lpParam,
|
||||||
|
const char* skuID) = 0;
|
||||||
|
virtual void DownloadAlreadyPurchased(CallbackFunc cb, void* lpParam,
|
||||||
|
const char* skuID) = 0;
|
||||||
|
#if defined(__ORBIS__) || defined(__PSVITA__)
|
||||||
|
virtual void Checkout_Game(CallbackFunc cb, void* lpParam,
|
||||||
|
const char* skuID) = 0;
|
||||||
|
virtual void DownloadAlreadyPurchased_Game(CallbackFunc cb, void* lpParam,
|
||||||
|
const char* skuID) = 0;
|
||||||
#endif
|
#endif
|
||||||
virtual void UpgradeTrial(CallbackFunc cb, void* lpParam) = 0;
|
virtual void UpgradeTrial(CallbackFunc cb, void* lpParam) = 0;
|
||||||
virtual void CheckForTrialUpgradeKey() = 0;
|
virtual void CheckForTrialUpgradeKey() = 0;
|
||||||
virtual bool LicenseChecked() = 0;
|
virtual bool LicenseChecked() = 0;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,6 @@
|
||||||
#include "../../../Minecraft.World/Platform/stdafx.h"
|
#include "../../../Minecraft.World/Platform/stdafx.h"
|
||||||
#include "SonyHttp.h"
|
#include "SonyHttp.h"
|
||||||
|
|
||||||
|
|
||||||
#ifdef __PS3__
|
#ifdef __PS3__
|
||||||
#include "../../../../Platform/PS3/Network/SonyHttp_PS3.h"
|
#include "../../../../Platform/PS3/Network/SonyHttp_PS3.h"
|
||||||
SonyHttp_PS3 g_SonyHttp;
|
SonyHttp_PS3 g_SonyHttp;
|
||||||
|
|
@ -16,19 +15,11 @@ SonyHttp_Vita g_SonyHttp;
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
bool SonyHttp::init() { return g_SonyHttp.init(); }
|
||||||
|
|
||||||
|
void SonyHttp::shutdown() { g_SonyHttp.shutdown(); }
|
||||||
|
|
||||||
bool SonyHttp::init()
|
bool SonyHttp::getDataFromURL(const char* szURL, void** ppOutData,
|
||||||
{
|
int* pDataSize) {
|
||||||
return g_SonyHttp.init();
|
return g_SonyHttp.getDataFromURL(szURL, ppOutData, pDataSize);
|
||||||
}
|
|
||||||
|
|
||||||
void SonyHttp::shutdown()
|
|
||||||
{
|
|
||||||
g_SonyHttp.shutdown();
|
|
||||||
}
|
|
||||||
|
|
||||||
bool SonyHttp::getDataFromURL(const char* szURL, void** ppOutData, int* pDataSize)
|
|
||||||
{
|
|
||||||
return g_SonyHttp.getDataFromURL(szURL, ppOutData, pDataSize);
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,11 +1,9 @@
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
|
class SonyHttp {
|
||||||
|
|
||||||
class SonyHttp
|
|
||||||
{
|
|
||||||
public:
|
public:
|
||||||
static bool init();
|
static bool init();
|
||||||
static void shutdown();
|
static void shutdown();
|
||||||
static bool getDataFromURL(const char* szURL, void** ppOutData, int* pDataSize);
|
static bool getDataFromURL(const char* szURL, void** ppOutData,
|
||||||
|
int* pDataSize);
|
||||||
};
|
};
|
||||||
|
|
@ -3,7 +3,6 @@
|
||||||
#include "../../../Minecraft.World/Platform/stdafx.h"
|
#include "../../../Minecraft.World/Platform/stdafx.h"
|
||||||
#include "SonyRemoteStorage.h"
|
#include "SonyRemoteStorage.h"
|
||||||
|
|
||||||
|
|
||||||
static const char sc_remoteSaveFilename[] = "/minecraft_save/gamedata.rs";
|
static const char sc_remoteSaveFilename[] = "/minecraft_save/gamedata.rs";
|
||||||
#ifdef __PSVITA__
|
#ifdef __PSVITA__
|
||||||
static const char sc_localSaveFilename[] = "CloudSave_Vita.bin";
|
static const char sc_localSaveFilename[] = "CloudSave_Vita.bin";
|
||||||
|
|
@ -18,323 +17,278 @@ static const char sc_localSaveFullPath[] = "/app0/CloudSave_Orbis.bin";
|
||||||
|
|
||||||
static SceRemoteStorageStatus statParams;
|
static SceRemoteStorageStatus statParams;
|
||||||
|
|
||||||
|
// void remoteStorageGetCallback(void* lpParam, SonyRemoteStorage::Status s, int
|
||||||
|
// error_code)
|
||||||
|
|
||||||
// void remoteStorageGetCallback(void* lpParam, SonyRemoteStorage::Status s, int error_code)
|
|
||||||
// {
|
// {
|
||||||
// app.DebugPrintf("remoteStorageGetCallback err : 0x%08x\n");
|
// app.DebugPrintf("remoteStorageGetCallback err : 0x%08x\n");
|
||||||
// }
|
// }
|
||||||
//
|
//
|
||||||
// void remoteStorageCallback(void* lpParam, SonyRemoteStorage::Status s, int error_code)
|
// void remoteStorageCallback(void* lpParam, SonyRemoteStorage::Status s, int
|
||||||
|
// error_code)
|
||||||
// {
|
// {
|
||||||
// app.DebugPrintf("remoteStorageCallback err : 0x%08x\n");
|
// app.DebugPrintf("remoteStorageCallback err : 0x%08x\n");
|
||||||
//
|
//
|
||||||
// app.getRemoteStorage()->getRemoteFileInfo(&statParams, remoteStorageGetInfoCallback, NULL);
|
// app.getRemoteStorage()->getRemoteFileInfo(&statParams,
|
||||||
|
// remoteStorageGetInfoCallback, NULL);
|
||||||
// }
|
// }
|
||||||
|
|
||||||
|
void getSaveInfoReturnCallback(void* lpParam, SonyRemoteStorage::Status s,
|
||||||
|
int error_code) {
|
||||||
|
SonyRemoteStorage* pRemoteStorage = (SonyRemoteStorage*)lpParam;
|
||||||
|
app.DebugPrintf("remoteStorageGetInfoCallback err : 0x%08x\n", error_code);
|
||||||
|
if (error_code == 0) {
|
||||||
|
for (int i = 0; i < statParams.numFiles; i++) {
|
||||||
|
if (strcmp(statParams.data[i].fileName, sc_remoteSaveFilename) ==
|
||||||
void getSaveInfoReturnCallback(void* lpParam, SonyRemoteStorage::Status s, int error_code)
|
0) {
|
||||||
{
|
// found the file we need in the cloud
|
||||||
SonyRemoteStorage* pRemoteStorage = (SonyRemoteStorage*)lpParam;
|
pRemoteStorage->m_getInfoStatus =
|
||||||
app.DebugPrintf("remoteStorageGetInfoCallback err : 0x%08x\n", error_code);
|
SonyRemoteStorage::e_infoFound;
|
||||||
if(error_code == 0)
|
pRemoteStorage->m_remoteFileInfo = &statParams.data[i];
|
||||||
{
|
}
|
||||||
for(int i=0;i<statParams.numFiles;i++)
|
}
|
||||||
{
|
}
|
||||||
if(strcmp(statParams.data[i].fileName, sc_remoteSaveFilename) == 0)
|
if (pRemoteStorage->m_getInfoStatus != SonyRemoteStorage::e_infoFound)
|
||||||
{
|
pRemoteStorage->m_getInfoStatus = SonyRemoteStorage::e_noInfoFound;
|
||||||
// found the file we need in the cloud
|
|
||||||
pRemoteStorage->m_getInfoStatus = SonyRemoteStorage::e_infoFound;
|
|
||||||
pRemoteStorage->m_remoteFileInfo = &statParams.data[i];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if(pRemoteStorage->m_getInfoStatus != SonyRemoteStorage::e_infoFound)
|
|
||||||
pRemoteStorage->m_getInfoStatus = SonyRemoteStorage::e_noInfoFound;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void getSaveInfoInitCallback(void* lpParam, SonyRemoteStorage::Status s,
|
||||||
|
int error_code) {
|
||||||
|
SonyRemoteStorage* pRemoteStorage = (SonyRemoteStorage*)lpParam;
|
||||||
|
if (error_code != 0) {
|
||||||
|
app.DebugPrintf("getSaveInfoInitCallback err : 0x%08x\n", error_code);
|
||||||
static void getSaveInfoInitCallback(void* lpParam, SonyRemoteStorage::Status s, int error_code)
|
pRemoteStorage->m_getInfoStatus = SonyRemoteStorage::e_noInfoFound;
|
||||||
{
|
} else {
|
||||||
SonyRemoteStorage* pRemoteStorage = (SonyRemoteStorage*)lpParam;
|
app.DebugPrintf("getSaveInfoInitCallback calling getRemoteFileInfo\n");
|
||||||
if(error_code != 0)
|
app.getRemoteStorage()->getRemoteFileInfo(
|
||||||
{
|
&statParams, getSaveInfoReturnCallback, pRemoteStorage);
|
||||||
app.DebugPrintf("getSaveInfoInitCallback err : 0x%08x\n", error_code);
|
}
|
||||||
pRemoteStorage->m_getInfoStatus = SonyRemoteStorage::e_noInfoFound;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
app.DebugPrintf("getSaveInfoInitCallback calling getRemoteFileInfo\n");
|
|
||||||
app.getRemoteStorage()->getRemoteFileInfo(&statParams, getSaveInfoReturnCallback, pRemoteStorage);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void SonyRemoteStorage::getSaveInfo()
|
void SonyRemoteStorage::getSaveInfo() {
|
||||||
{
|
if (m_getInfoStatus == e_gettingInfo) {
|
||||||
if(m_getInfoStatus == e_gettingInfo)
|
app.DebugPrintf("SonyRemoteStorage::getSaveInfo already running!!!\n");
|
||||||
{
|
return;
|
||||||
app.DebugPrintf("SonyRemoteStorage::getSaveInfo already running!!!\n");
|
}
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
m_getInfoStatus = e_gettingInfo;
|
m_getInfoStatus = e_gettingInfo;
|
||||||
if(!ProfileManager.IsSignedInLive(ProfileManager.GetPrimaryPad()))
|
if (!ProfileManager.IsSignedInLive(ProfileManager.GetPrimaryPad())) {
|
||||||
{
|
m_getInfoStatus = e_noInfoFound;
|
||||||
m_getInfoStatus = e_noInfoFound;
|
return;
|
||||||
return;
|
}
|
||||||
}
|
app.DebugPrintf("SonyRemoteStorage::getSaveInfo calling init\n");
|
||||||
app.DebugPrintf("SonyRemoteStorage::getSaveInfo calling init\n");
|
|
||||||
|
|
||||||
bool bOK = init(getSaveInfoInitCallback, this);
|
bool bOK = init(getSaveInfoInitCallback, this);
|
||||||
if(!bOK)
|
if (!bOK) m_getInfoStatus = e_noInfoFound;
|
||||||
m_getInfoStatus = e_noInfoFound;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool SonyRemoteStorage::getSaveData( const char* localDirname, CallbackFunc cb, void* lpParam )
|
bool SonyRemoteStorage::getSaveData(const char* localDirname, CallbackFunc cb,
|
||||||
{
|
void* lpParam) {
|
||||||
m_startTime = System::currentTimeMillis();
|
m_startTime = System::currentTimeMillis();
|
||||||
m_dataProgress = 0;
|
m_dataProgress = 0;
|
||||||
return getData(sc_remoteSaveFilename, localDirname, cb, lpParam);
|
return getData(sc_remoteSaveFilename, localDirname, cb, lpParam);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void setSaveDataInitCallback(void* lpParam, SonyRemoteStorage::Status s,
|
||||||
static void setSaveDataInitCallback(void* lpParam, SonyRemoteStorage::Status s, int error_code)
|
int error_code) {
|
||||||
{
|
SonyRemoteStorage* pRemoteStorage = (SonyRemoteStorage*)lpParam;
|
||||||
SonyRemoteStorage* pRemoteStorage = (SonyRemoteStorage*)lpParam;
|
if (error_code != 0) {
|
||||||
if(error_code != 0)
|
app.DebugPrintf("setSaveDataInitCallback err : 0x%08x\n", error_code);
|
||||||
{
|
pRemoteStorage->m_setDataStatus =
|
||||||
app.DebugPrintf("setSaveDataInitCallback err : 0x%08x\n", error_code);
|
SonyRemoteStorage::e_settingDataFailed;
|
||||||
pRemoteStorage->m_setDataStatus = SonyRemoteStorage::e_settingDataFailed;
|
if (pRemoteStorage->m_initCallbackFunc)
|
||||||
if(pRemoteStorage->m_initCallbackFunc)
|
pRemoteStorage->m_initCallbackFunc(
|
||||||
pRemoteStorage->m_initCallbackFunc(pRemoteStorage->m_initCallbackParam, s, error_code);
|
pRemoteStorage->m_initCallbackParam, s, error_code);
|
||||||
}
|
} else {
|
||||||
else
|
app.getRemoteStorage()->setData(pRemoteStorage->m_setSaveDataInfo,
|
||||||
{
|
pRemoteStorage->m_initCallbackFunc,
|
||||||
app.getRemoteStorage()->setData(pRemoteStorage->m_setSaveDataInfo, pRemoteStorage->m_initCallbackFunc, pRemoteStorage->m_initCallbackParam);
|
pRemoteStorage->m_initCallbackParam);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
bool SonyRemoteStorage::setSaveData(PSAVE_INFO info, CallbackFunc cb, void* lpParam)
|
bool SonyRemoteStorage::setSaveData(PSAVE_INFO info, CallbackFunc cb,
|
||||||
{
|
void* lpParam) {
|
||||||
m_setSaveDataInfo = info;
|
m_setSaveDataInfo = info;
|
||||||
m_setDataStatus = e_settingData;
|
m_setDataStatus = e_settingData;
|
||||||
m_initCallbackFunc = cb;
|
m_initCallbackFunc = cb;
|
||||||
m_initCallbackParam = lpParam;
|
m_initCallbackParam = lpParam;
|
||||||
m_dataProgress = 0;
|
m_dataProgress = 0;
|
||||||
bool bOK = init(setSaveDataInitCallback, this);
|
bool bOK = init(setSaveDataInitCallback, this);
|
||||||
if(!bOK)
|
if (!bOK) m_setDataStatus = e_settingDataFailed;
|
||||||
m_setDataStatus = e_settingDataFailed;
|
|
||||||
|
|
||||||
return bOK;
|
return bOK;
|
||||||
}
|
}
|
||||||
|
|
||||||
const char* SonyRemoteStorage::getLocalFilename()
|
const char* SonyRemoteStorage::getLocalFilename() {
|
||||||
{
|
return sc_localSaveFullPath;
|
||||||
return sc_localSaveFullPath;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const char* SonyRemoteStorage::getSaveNameUTF8()
|
const char* SonyRemoteStorage::getSaveNameUTF8() {
|
||||||
{
|
if (m_getInfoStatus != e_infoFound) return NULL;
|
||||||
if(m_getInfoStatus != e_infoFound)
|
DescriptionData* pDescData =
|
||||||
return NULL;
|
(DescriptionData*)m_remoteFileInfo->fileDescription;
|
||||||
DescriptionData* pDescData = (DescriptionData*)m_remoteFileInfo->fileDescription;
|
return pDescData->m_saveNameUTF8;
|
||||||
return pDescData->m_saveNameUTF8;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
ESavePlatform SonyRemoteStorage::getSavePlatform()
|
ESavePlatform SonyRemoteStorage::getSavePlatform() {
|
||||||
{
|
if (m_getInfoStatus != e_infoFound) return SAVE_FILE_PLATFORM_NONE;
|
||||||
if(m_getInfoStatus != e_infoFound)
|
DescriptionData* pDescData =
|
||||||
return SAVE_FILE_PLATFORM_NONE;
|
(DescriptionData*)m_remoteFileInfo->fileDescription;
|
||||||
DescriptionData* pDescData = (DescriptionData*)m_remoteFileInfo->fileDescription;
|
return (ESavePlatform)MAKE_FOURCC(
|
||||||
return (ESavePlatform)MAKE_FOURCC(pDescData->m_platform[0], pDescData->m_platform[1], pDescData->m_platform[2], pDescData->m_platform[3]);
|
pDescData->m_platform[0], pDescData->m_platform[1],
|
||||||
|
pDescData->m_platform[2], pDescData->m_platform[3]);
|
||||||
}
|
}
|
||||||
|
|
||||||
__int64 SonyRemoteStorage::getSaveSeed()
|
__int64 SonyRemoteStorage::getSaveSeed() {
|
||||||
{
|
if (m_getInfoStatus != e_infoFound) return 0;
|
||||||
if(m_getInfoStatus != e_infoFound)
|
DescriptionData* pDescData =
|
||||||
return 0;
|
(DescriptionData*)m_remoteFileInfo->fileDescription;
|
||||||
DescriptionData* pDescData = (DescriptionData*)m_remoteFileInfo->fileDescription;
|
|
||||||
|
|
||||||
char seedString[17];
|
char seedString[17];
|
||||||
ZeroMemory(seedString,17);
|
ZeroMemory(seedString, 17);
|
||||||
memcpy(seedString, pDescData->m_seed,16);
|
memcpy(seedString, pDescData->m_seed, 16);
|
||||||
|
|
||||||
__uint64 seed = 0;
|
__uint64 seed = 0;
|
||||||
std::stringstream ss;
|
std::stringstream ss;
|
||||||
ss << seedString;
|
ss << seedString;
|
||||||
ss >> std::hex >> seed;
|
ss >> std::hex >> seed;
|
||||||
return seed;
|
return seed;
|
||||||
}
|
}
|
||||||
|
|
||||||
unsigned int SonyRemoteStorage::getSaveHostOptions()
|
unsigned int SonyRemoteStorage::getSaveHostOptions() {
|
||||||
{
|
if (m_getInfoStatus != e_infoFound) return 0;
|
||||||
if(m_getInfoStatus != e_infoFound)
|
DescriptionData* pDescData =
|
||||||
return 0;
|
(DescriptionData*)m_remoteFileInfo->fileDescription;
|
||||||
DescriptionData* pDescData = (DescriptionData*)m_remoteFileInfo->fileDescription;
|
|
||||||
|
|
||||||
char optionsString[9];
|
char optionsString[9];
|
||||||
ZeroMemory(optionsString,9);
|
ZeroMemory(optionsString, 9);
|
||||||
memcpy(optionsString, pDescData->m_hostOptions,8);
|
memcpy(optionsString, pDescData->m_hostOptions, 8);
|
||||||
|
|
||||||
unsigned int uiHostOptions = 0;
|
unsigned int uiHostOptions = 0;
|
||||||
std::stringstream ss;
|
std::stringstream ss;
|
||||||
ss << optionsString;
|
ss << optionsString;
|
||||||
ss >> std::hex >> uiHostOptions;
|
ss >> std::hex >> uiHostOptions;
|
||||||
return uiHostOptions;
|
return uiHostOptions;
|
||||||
}
|
}
|
||||||
|
|
||||||
unsigned int SonyRemoteStorage::getSaveTexturePack()
|
unsigned int SonyRemoteStorage::getSaveTexturePack() {
|
||||||
{
|
if (m_getInfoStatus != e_infoFound) return 0;
|
||||||
if(m_getInfoStatus != e_infoFound)
|
DescriptionData* pDescData =
|
||||||
return 0;
|
(DescriptionData*)m_remoteFileInfo->fileDescription;
|
||||||
DescriptionData* pDescData = (DescriptionData*)m_remoteFileInfo->fileDescription;
|
|
||||||
|
|
||||||
char textureString[9];
|
char textureString[9];
|
||||||
ZeroMemory(textureString,9);
|
ZeroMemory(textureString, 9);
|
||||||
memcpy(textureString, pDescData->m_texturePack,8);
|
memcpy(textureString, pDescData->m_texturePack, 8);
|
||||||
|
|
||||||
unsigned int uiTexturePack = 0;
|
unsigned int uiTexturePack = 0;
|
||||||
std::stringstream ss;
|
std::stringstream ss;
|
||||||
ss << textureString;
|
ss << textureString;
|
||||||
ss >> std::hex >> uiTexturePack;
|
ss >> std::hex >> uiTexturePack;
|
||||||
return uiTexturePack;
|
return uiTexturePack;
|
||||||
}
|
}
|
||||||
|
|
||||||
const char* SonyRemoteStorage::getRemoteSaveFilename()
|
const char* SonyRemoteStorage::getRemoteSaveFilename() {
|
||||||
{
|
return sc_remoteSaveFilename;
|
||||||
return sc_remoteSaveFilename;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int SonyRemoteStorage::getSaveFilesize()
|
int SonyRemoteStorage::getSaveFilesize() {
|
||||||
{
|
if (m_getInfoStatus == e_infoFound) {
|
||||||
if(m_getInfoStatus == e_infoFound)
|
return m_remoteFileInfo->fileSize;
|
||||||
{
|
}
|
||||||
return m_remoteFileInfo->fileSize;
|
return 0;
|
||||||
}
|
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool SonyRemoteStorage::setData(PSAVE_INFO info, CallbackFunc cb,
|
||||||
|
void* lpParam) {
|
||||||
|
m_setDataSaveInfo = info;
|
||||||
|
m_callbackFunc = cb;
|
||||||
|
m_callbackParam = lpParam;
|
||||||
|
m_status = e_setDataInProgress;
|
||||||
|
|
||||||
bool SonyRemoteStorage::setData( PSAVE_INFO info, CallbackFunc cb, void* lpParam )
|
C4JStorage::ESaveGameState eLoadStatus =
|
||||||
{
|
StorageManager.LoadSaveDataThumbnail(
|
||||||
m_setDataSaveInfo = info;
|
info, &LoadSaveDataThumbnailReturned, this);
|
||||||
m_callbackFunc = cb;
|
return true;
|
||||||
m_callbackParam = lpParam;
|
|
||||||
m_status = e_setDataInProgress;
|
|
||||||
|
|
||||||
C4JStorage::ESaveGameState eLoadStatus=StorageManager.LoadSaveDataThumbnail(info,&LoadSaveDataThumbnailReturned,this);
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int SonyRemoteStorage::LoadSaveDataThumbnailReturned(void *lpParam,std::uint8_t *thumbnailData,unsigned int thumbnailBytes)
|
int SonyRemoteStorage::LoadSaveDataThumbnailReturned(
|
||||||
{
|
void* lpParam, std::uint8_t* thumbnailData, unsigned int thumbnailBytes) {
|
||||||
SonyRemoteStorage *pClass= (SonyRemoteStorage *)lpParam;
|
SonyRemoteStorage* pClass = (SonyRemoteStorage*)lpParam;
|
||||||
|
|
||||||
if(pClass->m_bAborting)
|
if (pClass->m_bAborting) {
|
||||||
{
|
pClass->runCallback();
|
||||||
pClass->runCallback();
|
return 0;
|
||||||
return 0;
|
}
|
||||||
}
|
|
||||||
|
|
||||||
app.DebugPrintf("Received data for a thumbnail\n");
|
app.DebugPrintf("Received data for a thumbnail\n");
|
||||||
|
|
||||||
if(thumbnailData && thumbnailBytes)
|
if (thumbnailData && thumbnailBytes) {
|
||||||
{
|
pClass->m_thumbnailData = thumbnailData;
|
||||||
pClass->m_thumbnailData = thumbnailData;
|
pClass->m_thumbnailDataSize = thumbnailBytes;
|
||||||
pClass->m_thumbnailDataSize = thumbnailBytes;
|
} else {
|
||||||
}
|
app.DebugPrintf("Thumbnail data is NULL, or has size 0\n");
|
||||||
else
|
pClass->m_thumbnailData = NULL;
|
||||||
{
|
pClass->m_thumbnailDataSize = 0;
|
||||||
app.DebugPrintf("Thumbnail data is NULL, or has size 0\n");
|
}
|
||||||
pClass->m_thumbnailData = NULL;
|
|
||||||
pClass->m_thumbnailDataSize = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
if(pClass->m_SetDataThread != NULL)
|
if (pClass->m_SetDataThread != NULL) delete pClass->m_SetDataThread;
|
||||||
delete pClass->m_SetDataThread;
|
|
||||||
|
|
||||||
pClass->m_SetDataThread = new C4JThread(setDataThread, pClass, "setDataThread");
|
pClass->m_SetDataThread =
|
||||||
pClass->m_SetDataThread->Run();
|
new C4JThread(setDataThread, pClass, "setDataThread");
|
||||||
|
pClass->m_SetDataThread->Run();
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int SonyRemoteStorage::setDataThread(void* lpParam)
|
int SonyRemoteStorage::setDataThread(void* lpParam) {
|
||||||
{
|
SonyRemoteStorage* pClass = (SonyRemoteStorage*)lpParam;
|
||||||
SonyRemoteStorage* pClass = (SonyRemoteStorage*)lpParam;
|
pClass->m_startTime = System::currentTimeMillis();
|
||||||
pClass->m_startTime = System::currentTimeMillis();
|
pClass->setDataInternal();
|
||||||
pClass->setDataInternal();
|
return 0;
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool SonyRemoteStorage::saveIsAvailable()
|
bool SonyRemoteStorage::saveIsAvailable() {
|
||||||
{
|
if (m_getInfoStatus != e_infoFound) return false;
|
||||||
if(m_getInfoStatus != e_infoFound)
|
|
||||||
return false;
|
|
||||||
#ifdef __PS3__
|
#ifdef __PS3__
|
||||||
return (getSavePlatform() == SAVE_FILE_PLATFORM_PSVITA);
|
return (getSavePlatform() == SAVE_FILE_PLATFORM_PSVITA);
|
||||||
#elif defined __PSVITA__
|
#elif defined __PSVITA__
|
||||||
return (getSavePlatform() == SAVE_FILE_PLATFORM_PS3);
|
return (getSavePlatform() == SAVE_FILE_PLATFORM_PS3);
|
||||||
#else // __ORBIS__
|
#else // __ORBIS__
|
||||||
return true;
|
return true;
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
int SonyRemoteStorage::getDataProgress()
|
int SonyRemoteStorage::getDataProgress() {
|
||||||
{
|
__int64 time = System::currentTimeMillis();
|
||||||
__int64 time = System::currentTimeMillis();
|
int elapsedSecs = (time - m_startTime) / 1000;
|
||||||
int elapsedSecs = (time - m_startTime) / 1000;
|
int progVal = m_dataProgress + (elapsedSecs / 3);
|
||||||
int progVal = m_dataProgress + (elapsedSecs/3);
|
if (progVal > 95) {
|
||||||
if(progVal > 95)
|
return m_dataProgress;
|
||||||
{
|
}
|
||||||
return m_dataProgress;
|
return progVal;
|
||||||
}
|
|
||||||
return progVal;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool SonyRemoteStorage::shutdown() {
|
||||||
bool SonyRemoteStorage::shutdown()
|
if (m_bInitialised) {
|
||||||
{
|
int ret = sceRemoteStorageTerm();
|
||||||
if(m_bInitialised)
|
if (ret >= 0) {
|
||||||
{
|
app.DebugPrintf("Term request done \n");
|
||||||
int ret = sceRemoteStorageTerm();
|
m_bInitialised = false;
|
||||||
if(ret >= 0)
|
free(m_memPoolBuffer);
|
||||||
{
|
m_memPoolBuffer = NULL;
|
||||||
app.DebugPrintf("Term request done \n");
|
return true;
|
||||||
m_bInitialised = false;
|
} else {
|
||||||
free(m_memPoolBuffer);
|
app.DebugPrintf("Error in Term request: 0x%x \n", ret);
|
||||||
m_memPoolBuffer = NULL;
|
return false;
|
||||||
return true;
|
}
|
||||||
}
|
}
|
||||||
else
|
return true;
|
||||||
{
|
|
||||||
app.DebugPrintf("Error in Term request: 0x%x \n", ret);
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void SonyRemoteStorage::waitForStorageManagerIdle() {
|
||||||
void SonyRemoteStorage::waitForStorageManagerIdle()
|
C4JStorage::ESaveGameState storageState = StorageManager.GetSaveState();
|
||||||
{
|
while (storageState != C4JStorage::ESaveGame_Idle) {
|
||||||
C4JStorage::ESaveGameState storageState = StorageManager.GetSaveState();
|
Sleep(10);
|
||||||
while(storageState != C4JStorage::ESaveGame_Idle)
|
// app.DebugPrintf(">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
|
||||||
{
|
// >>>>> storageState = %d\n", storageState);
|
||||||
Sleep(10);
|
storageState = StorageManager.GetSaveState();
|
||||||
// app.DebugPrintf(">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> >>>>> storageState = %d\n", storageState);
|
}
|
||||||
storageState = StorageManager.GetSaveState();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,121 +1,114 @@
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
|
|
||||||
#include "sceRemoteStorage/header/sceRemoteStorage.h"
|
#include "sceRemoteStorage/header/sceRemoteStorage.h"
|
||||||
|
|
||||||
#include <cstdint>
|
#include <cstdint>
|
||||||
|
|
||||||
class SonyRemoteStorage
|
class SonyRemoteStorage {
|
||||||
{
|
|
||||||
public:
|
public:
|
||||||
enum Status
|
enum Status {
|
||||||
{
|
e_idle,
|
||||||
e_idle,
|
e_accountLinked,
|
||||||
e_accountLinked,
|
e_error,
|
||||||
e_error,
|
e_signInRequired,
|
||||||
e_signInRequired,
|
e_compressInProgress,
|
||||||
e_compressInProgress,
|
e_setDataInProgress,
|
||||||
e_setDataInProgress,
|
e_setDataSucceeded,
|
||||||
e_setDataSucceeded,
|
e_getDataInProgress,
|
||||||
e_getDataInProgress,
|
e_getDataSucceeded,
|
||||||
e_getDataSucceeded,
|
e_getStatusInProgress,
|
||||||
e_getStatusInProgress,
|
e_getStatusSucceeded
|
||||||
e_getStatusSucceeded
|
};
|
||||||
};
|
typedef void (*CallbackFunc)(void* lpParam, Status s, int error_code);
|
||||||
typedef void (*CallbackFunc)(void* lpParam, Status s, int error_code);
|
|
||||||
|
|
||||||
enum GetInfoStatus
|
enum GetInfoStatus { e_gettingInfo, e_infoFound, e_noInfoFound };
|
||||||
{
|
GetInfoStatus m_getInfoStatus;
|
||||||
e_gettingInfo,
|
|
||||||
e_infoFound,
|
|
||||||
e_noInfoFound
|
|
||||||
};
|
|
||||||
GetInfoStatus m_getInfoStatus;
|
|
||||||
|
|
||||||
enum SetDataStatus
|
enum SetDataStatus {
|
||||||
{
|
e_settingData,
|
||||||
e_settingData,
|
e_settingDataFailed,
|
||||||
e_settingDataFailed,
|
e_settingDataSucceeded
|
||||||
e_settingDataSucceeded
|
};
|
||||||
};
|
SetDataStatus m_setDataStatus;
|
||||||
SetDataStatus m_setDataStatus;
|
|
||||||
|
|
||||||
PSAVE_INFO m_setSaveDataInfo;
|
PSAVE_INFO m_setSaveDataInfo;
|
||||||
SceRemoteStorageData* m_remoteFileInfo;
|
SceRemoteStorageData* m_remoteFileInfo;
|
||||||
|
|
||||||
class DescriptionData
|
class DescriptionData {
|
||||||
{
|
// this stuff is read from a JSON query, so it all has to be text based,
|
||||||
// this stuff is read from a JSON query, so it all has to be text based, max 256 bytes
|
// max 256 bytes
|
||||||
public:
|
public:
|
||||||
char m_platform[4];
|
char m_platform[4];
|
||||||
char m_seed[16]; // 8 bytes as hex
|
char m_seed[16]; // 8 bytes as hex
|
||||||
char m_hostOptions[8]; // 4 bytes as hex
|
char m_hostOptions[8]; // 4 bytes as hex
|
||||||
char m_texturePack[8]; // 4 bytes as hex
|
char m_texturePack[8]; // 4 bytes as hex
|
||||||
char m_saveNameUTF8[128];
|
char m_saveNameUTF8[128];
|
||||||
};
|
};
|
||||||
|
|
||||||
CallbackFunc m_callbackFunc;
|
CallbackFunc m_callbackFunc;
|
||||||
void* m_callbackParam;
|
void* m_callbackParam;
|
||||||
|
|
||||||
|
CallbackFunc m_initCallbackFunc;
|
||||||
|
void* m_initCallbackParam;
|
||||||
|
|
||||||
CallbackFunc m_initCallbackFunc;
|
void getSaveInfo();
|
||||||
void* m_initCallbackParam;
|
bool waitingForSaveInfo() { return (m_getInfoStatus == e_gettingInfo); }
|
||||||
|
bool saveIsAvailable();
|
||||||
|
|
||||||
void getSaveInfo();
|
int getSaveFilesize();
|
||||||
bool waitingForSaveInfo() { return (m_getInfoStatus == e_gettingInfo); }
|
bool getSaveData(const char* localDirname, CallbackFunc cb, void* lpParam);
|
||||||
bool saveIsAvailable();
|
|
||||||
|
|
||||||
int getSaveFilesize();
|
bool setSaveData(PSAVE_INFO info, CallbackFunc cb, void* lpParam);
|
||||||
bool getSaveData(const char* localDirname, CallbackFunc cb, void* lpParam);
|
bool waitingForSetData() { return (m_setDataStatus == e_settingData); }
|
||||||
|
|
||||||
bool setSaveData(PSAVE_INFO info, CallbackFunc cb, void* lpParam);
|
const char* getLocalFilename();
|
||||||
bool waitingForSetData() { return (m_setDataStatus == e_settingData); }
|
const char* getSaveNameUTF8();
|
||||||
|
ESavePlatform getSavePlatform();
|
||||||
|
__int64 getSaveSeed();
|
||||||
|
unsigned int getSaveHostOptions();
|
||||||
|
unsigned int getSaveTexturePack();
|
||||||
|
|
||||||
const char* getLocalFilename();
|
void SetServiceID(char* pchServiceID) { m_pchServiceID = pchServiceID; }
|
||||||
const char* getSaveNameUTF8();
|
|
||||||
ESavePlatform getSavePlatform();
|
|
||||||
__int64 getSaveSeed();
|
|
||||||
unsigned int getSaveHostOptions();
|
|
||||||
unsigned int getSaveTexturePack();
|
|
||||||
|
|
||||||
void SetServiceID(char *pchServiceID) { m_pchServiceID=pchServiceID; }
|
virtual bool init(CallbackFunc cb, void* lpParam) = 0;
|
||||||
|
virtual bool getRemoteFileInfo(SceRemoteStorageStatus* pInfo,
|
||||||
|
CallbackFunc cb, void* lpParam) = 0;
|
||||||
|
virtual bool getData(const char* remotePath, const char* localPath,
|
||||||
|
CallbackFunc cb, void* lpParam) = 0;
|
||||||
|
virtual void abort() = 0;
|
||||||
|
virtual bool shutdown();
|
||||||
|
virtual bool setDataInternal() = 0;
|
||||||
|
virtual void runCallback() = 0;
|
||||||
|
|
||||||
virtual bool init(CallbackFunc cb, void* lpParam) = 0;
|
Status getStatus() { return m_status; }
|
||||||
virtual bool getRemoteFileInfo(SceRemoteStorageStatus* pInfo, CallbackFunc cb, void* lpParam) = 0;
|
int getDataProgress();
|
||||||
virtual bool getData(const char* remotePath, const char* localPath, CallbackFunc cb, void* lpParam) = 0;
|
void waitForStorageManagerIdle();
|
||||||
virtual void abort() = 0;
|
|
||||||
virtual bool shutdown();
|
|
||||||
virtual bool setDataInternal() = 0;
|
|
||||||
virtual void runCallback() = 0;
|
|
||||||
|
|
||||||
|
bool setData(PSAVE_INFO info, CallbackFunc cb, void* lpParam);
|
||||||
|
static int LoadSaveDataThumbnailReturned(void* lpParam,
|
||||||
|
std::uint8_t* thumbnailData,
|
||||||
|
unsigned int thumbnailBytes);
|
||||||
|
static int setDataThread(void* lpParam);
|
||||||
|
|
||||||
Status getStatus() { return m_status; }
|
SonyRemoteStorage()
|
||||||
int getDataProgress();
|
: m_memPoolBuffer(NULL),
|
||||||
void waitForStorageManagerIdle();
|
m_bInitialised(false),
|
||||||
|
m_getInfoStatus(e_noInfoFound) {}
|
||||||
|
|
||||||
|
|
||||||
bool setData( PSAVE_INFO info, CallbackFunc cb, void* lpParam );
|
|
||||||
static int LoadSaveDataThumbnailReturned(void *lpParam,std::uint8_t *thumbnailData,unsigned int thumbnailBytes);
|
|
||||||
static int setDataThread(void* lpParam);
|
|
||||||
|
|
||||||
SonyRemoteStorage() : m_memPoolBuffer(NULL), m_bInitialised(false),m_getInfoStatus(e_noInfoFound) {}
|
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
const char* getRemoteSaveFilename();
|
const char* getRemoteSaveFilename();
|
||||||
bool m_bInitialised;
|
bool m_bInitialised;
|
||||||
void* m_memPoolBuffer;
|
void* m_memPoolBuffer;
|
||||||
Status m_status;
|
Status m_status;
|
||||||
int m_dataProgress;
|
int m_dataProgress;
|
||||||
char *m_pchServiceID;
|
char* m_pchServiceID;
|
||||||
|
|
||||||
std::uint8_t *m_thumbnailData;
|
std::uint8_t* m_thumbnailData;
|
||||||
unsigned int m_thumbnailDataSize;
|
unsigned int m_thumbnailDataSize;
|
||||||
C4JThread* m_SetDataThread;
|
C4JThread* m_SetDataThread;
|
||||||
PSAVE_INFO m_setDataSaveInfo;
|
PSAVE_INFO m_setDataSaveInfo;
|
||||||
__int64 m_startTime;
|
__int64 m_startTime;
|
||||||
|
|
||||||
bool m_bAborting;
|
|
||||||
bool m_bTransferStarted;
|
|
||||||
|
|
||||||
|
bool m_bAborting;
|
||||||
|
bool m_bTransferStarted;
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -7,131 +7,212 @@
|
||||||
/// @brief
|
/// @brief
|
||||||
/// Initialises the RemoteStorage library.
|
/// Initialises the RemoteStorage library.
|
||||||
///
|
///
|
||||||
/// Initialises the RemoteStorage library, creates a session on the server and starts the Thread to process requests.
|
/// Initialises the RemoteStorage library, creates a session on the server and
|
||||||
/// This method must be executed to start the RemoteStorage library or none of its functionality will be available.
|
/// starts the Thread to process requests. This method must be executed to start
|
||||||
/// This method will block while it initializes its thread and will return an error if it is
|
/// the RemoteStorage library or none of its functionality will be available.
|
||||||
/// unable to do so. The session will be created on the thread once this is created and it won't be a blocking operation.
|
/// This method will block while it initializes its thread and will return an
|
||||||
|
/// error if it is unable to do so. The session will be created on the thread
|
||||||
|
/// once this is created and it won't be a blocking operation.
|
||||||
///
|
///
|
||||||
/// It is important to note that HTTP, SSL and NET libraries are not being initialised by the library and should be initialised outside of it.
|
/// It is important to note that HTTP, SSL and NET libraries are not being
|
||||||
|
/// initialised by the library and should be initialised outside of it.
|
||||||
///
|
///
|
||||||
/// @param params The structure of type <>SceRemoteStorageInitParams</c> that contains necessary information to start the library.
|
/// @param params The structure of type
|
||||||
|
/// <>SceRemoteStorageInitParams</c> that contains necessary information to
|
||||||
|
/// start the library.
|
||||||
///
|
///
|
||||||
/// @retval SCE_REMOTE_STORAGE_SUCCESS The operation was successfully registered on the thread.
|
/// @retval SCE_REMOTE_STORAGE_SUCCESS
|
||||||
/// @retval SCE_REMOTE_STORAGE_ERROR_INVALID_ARGUMENT At least one of the arguments passed in the input structure is not valid.
|
/// The operation was successfully registered on the thread.
|
||||||
/// @retval SCE_REMOTE_STORAGE_ERROR_FAILED_TO_ALLOCATE There is no enough memory on the library to perform an allocation.
|
/// @retval SCE_REMOTE_STORAGE_ERROR_INVALID_ARGUMENT At least one of
|
||||||
/// @retval USER_ACCOUNT_LINKED This event will be sent to the event callback when the session is created and linked to PSN on the server
|
/// the arguments passed in the input structure is not valid.
|
||||||
/// @retval PSN_SIGN_IN_REQUIRED This event will be sent to the event callback when the session is created but not linked to PSN on the server.
|
/// @retval SCE_REMOTE_STORAGE_ERROR_FAILED_TO_ALLOCATE There is no
|
||||||
/// This will only happen on the PC version and requires to call <c>sceRemoteStorageOpenWebBrowser()</c> function.
|
/// enough memory on the library to perform an allocation.
|
||||||
/// @retval ERROR_OCCURRED This event will be sent to the event callback when an error has occurred in the thread.
|
/// @retval USER_ACCOUNT_LINKED
|
||||||
|
/// This event will be sent to the event callback when the session is created
|
||||||
|
/// and linked to PSN on the server
|
||||||
|
/// @retval PSN_SIGN_IN_REQUIRED
|
||||||
|
/// This event will be sent to the event callback when the session is created
|
||||||
|
/// but not linked to PSN on the server.
|
||||||
|
/// This
|
||||||
|
///will only happen on the PC version and requires to call
|
||||||
|
///<c>sceRemoteStorageOpenWebBrowser()</c> function.
|
||||||
|
/// @retval ERROR_OCCURRED
|
||||||
|
/// This event will be sent to the event callback when an error has occurred in
|
||||||
|
/// the thread.
|
||||||
///
|
///
|
||||||
/// @note System errors may be returned. Design your code so it does expect other errors.
|
/// @note System errors may be returned. Design your code so it does expect
|
||||||
int32_t sceRemoteStorageInit(const SceRemoteStorageInitParams & params);
|
/// other errors.
|
||||||
|
int32_t sceRemoteStorageInit(const SceRemoteStorageInitParams& params);
|
||||||
|
|
||||||
/// @brief
|
/// @brief
|
||||||
/// Terminates the RemoteStorage library.
|
/// Terminates the RemoteStorage library.
|
||||||
///
|
///
|
||||||
/// Terminates the RemoteStorage library and deletes the thread that process requests.
|
/// Terminates the RemoteStorage library and deletes the thread that process
|
||||||
/// This method must be executed to terminate the RemoteStorage library to prevent leaks in memory and resources.
|
/// requests. This method must be executed to terminate the RemoteStorage
|
||||||
/// This method will abort any other pending requests and terminate the library. It won't wait for requests to finish.
|
/// library to prevent leaks in memory and resources. This method will abort any
|
||||||
/// This method is synchronous and does not make use of the callback to inform the user of success termination. It is executed on the calling thread.
|
/// other pending requests and terminate the library. It won't wait for requests
|
||||||
|
/// to finish. This method is synchronous and does not make use of the callback
|
||||||
|
/// to inform the user of success termination. It is executed on the calling
|
||||||
|
/// thread.
|
||||||
///
|
///
|
||||||
/// @retval SCE_REMOTE_STORAGE_SUCCESS The operation was successful.
|
/// @retval SCE_REMOTE_STORAGE_SUCCESS
|
||||||
/// @retval SCE_REMOTE_STORAGE_ERROR_NOT_INITIALISED The RemoteStorage library was not initialised.
|
/// The operation was successful.
|
||||||
|
/// @retval SCE_REMOTE_STORAGE_ERROR_NOT_INITIALISED The
|
||||||
|
/// RemoteStorage library was not initialised.
|
||||||
///
|
///
|
||||||
/// @note System errors may be returned. Design your code so it does expect other errors.
|
/// @note System errors may be returned. Design your code so it does expect
|
||||||
|
/// other errors.
|
||||||
int32_t sceRemoteStorageTerm();
|
int32_t sceRemoteStorageTerm();
|
||||||
|
|
||||||
/// @brief
|
/// @brief
|
||||||
/// Aborts a request sent to the RemoteStorage library.
|
/// Aborts a request sent to the RemoteStorage library.
|
||||||
///
|
///
|
||||||
/// Aborts a request being processed or pending to be processed by the RemoteStorage library.
|
/// Aborts a request being processed or pending to be processed by the
|
||||||
/// This method is synchronous and does not make use of the callback to inform the user of success termination. It is executed on the calling thread.
|
/// RemoteStorage library. This method is synchronous and does not make use of
|
||||||
|
/// the callback to inform the user of success termination. It is executed on
|
||||||
|
/// the calling thread.
|
||||||
///
|
///
|
||||||
/// @param param A structure containing the request Id to be aborted.
|
/// @param param A structure containing the request Id to be aborted.
|
||||||
/// This request Id is provided by other functions (get/setData, getStatus and OpenWebBrowser) so they can be referenced.
|
/// This request Id is provided by other
|
||||||
|
///functions (get/setData, getStatus and OpenWebBrowser) so they can be
|
||||||
|
///referenced.
|
||||||
///
|
///
|
||||||
/// @retval SCE_REMOTE_STORAGE_SUCCESS The operation was successful.
|
/// @retval SCE_REMOTE_STORAGE_SUCCESS
|
||||||
/// @retval SCE_REMOTE_STORAGE_ERROR_NOT_INITIALISED The RemoteStorage library was not initialised.
|
/// The operation was successful.
|
||||||
/// @retval SCE_REMOTE_STORAGE_ERROR_REQ_ID_NOT_FOUND The request Id sent is not found.
|
/// @retval SCE_REMOTE_STORAGE_ERROR_NOT_INITIALISED The
|
||||||
|
/// RemoteStorage library was not initialised.
|
||||||
|
/// @retval SCE_REMOTE_STORAGE_ERROR_REQ_ID_NOT_FOUND The request Id
|
||||||
|
/// sent is not found.
|
||||||
///
|
///
|
||||||
/// @note System errors may be returned. Design your code so it does expect other errors.
|
/// @note System errors may be returned. Design your code so it does expect
|
||||||
int32_t sceRemoteStorageAbort(const SceRemoteStorageAbortReqParams & params);
|
/// other errors.
|
||||||
|
int32_t sceRemoteStorageAbort(const SceRemoteStorageAbortReqParams& params);
|
||||||
|
|
||||||
/// @brief
|
/// @brief
|
||||||
/// Opens the default web browser to sign in to PSN on PC.
|
/// Opens the default web browser to sign in to PSN on PC.
|
||||||
///
|
///
|
||||||
/// Opens the default web browser to sign in to PSN on PC. This function does not have any functionality on other platforms.
|
/// Opens the default web browser to sign in to PSN on PC. This function does
|
||||||
/// This method does make use of the callback to inform the user of success termination. This function has priority over other functions on the thread (as getData(), getStatus()
|
/// not have any functionality on other platforms. This method does make use of
|
||||||
/// and setData()) and it will be executed as soon as the thread finishes processing a pending request.
|
/// the callback to inform the user of success termination. This function has
|
||||||
|
/// priority over other functions on the thread (as getData(), getStatus() and
|
||||||
|
/// setData()) and it will be executed as soon as the thread finishes processing
|
||||||
|
/// a pending request.
|
||||||
///
|
///
|
||||||
/// @param param The structure containing extra parameters to be passed in. This structure does only exist for future expansions.
|
/// @param param The structure containing extra parameters to be
|
||||||
|
/// passed in. This structure does only exist for future expansions.
|
||||||
///
|
///
|
||||||
/// @retval SCE_REMOTE_STORAGE_SUCCESS The operation was successfully registered on the thread.
|
/// @retval SCE_REMOTE_STORAGE_SUCCESS
|
||||||
/// @retval SCE_REMOTE_STORAGE_ERROR_NOT_INITIALISED The RemoteStorage library was not initialised.
|
/// The operation was successfully registered on the thread.
|
||||||
/// @retval SCE_REMOTE_STORAGE_ERROR_FAILED_TO_ALLOCATE There is no enough memory on the library to perform an allocation.
|
/// @retval SCE_REMOTE_STORAGE_ERROR_NOT_INITIALISED The
|
||||||
/// @retval ERROR_OCCURRED This event will be sent to the event callback when an error has occurred in the thread.
|
/// RemoteStorage library was not initialised.
|
||||||
|
/// @retval SCE_REMOTE_STORAGE_ERROR_FAILED_TO_ALLOCATE There is no
|
||||||
|
/// enough memory on the library to perform an allocation.
|
||||||
|
/// @retval ERROR_OCCURRED
|
||||||
|
/// This event will be sent to the event callback when an error has occurred in
|
||||||
|
/// the thread.
|
||||||
///
|
///
|
||||||
/// @note System errors may be returned. Design your code so it does expect other errors.
|
/// @note System errors may be returned. Design your code so it does expect
|
||||||
int32_t sceRemoteStorageOpenWebBrowser(const SceRemoteStorageWebBrowserReqParams & params);
|
/// other errors.
|
||||||
|
int32_t sceRemoteStorageOpenWebBrowser(
|
||||||
|
const SceRemoteStorageWebBrowserReqParams& params);
|
||||||
|
|
||||||
/// @brief
|
/// @brief
|
||||||
/// Gives details for all files of a user.
|
/// Gives details for all files of a user.
|
||||||
///
|
///
|
||||||
/// Gives details for all files of a user. It provides generic information (remaining bandwidth per day, HDD space per user, number of files) as well as
|
/// Gives details for all files of a user. It provides generic information
|
||||||
/// specific file information (number of bytes, file name, file description, MD5 checksum, timestamp and file visibility). File data is not provided.
|
/// (remaining bandwidth per day, HDD space per user, number of files) as well
|
||||||
/// This method does make use of the callback to inform the user of success termination. The SceRemoteStorageStatus pointer must be pointer a to a valid
|
/// as specific file information (number of bytes, file name, file description,
|
||||||
/// location in memory until the callback is called as the output information will be stored in such location.
|
/// MD5 checksum, timestamp and file visibility). File data is not provided.
|
||||||
|
/// This method does make use of the callback to inform the user of success
|
||||||
|
/// termination. The SceRemoteStorageStatus pointer must be pointer a to a valid
|
||||||
|
/// location in memory until the callback is called as the output information
|
||||||
|
/// will be stored in such location.
|
||||||
///
|
///
|
||||||
/// @param params The structure containing extra parameters to be passed in. This structure does only exist for future expansions.
|
/// @param params The structure containing extra parameters to be
|
||||||
/// @param status The structure where the output information will be stored. The memory location being pointed must be valid until the callback gets called.
|
/// passed in. This structure does only exist for future expansions.
|
||||||
|
/// @param status The structure where the output information will
|
||||||
|
/// be stored. The memory location being pointed must be valid until the
|
||||||
|
/// callback gets called.
|
||||||
///
|
///
|
||||||
/// @retval SCE_REMOTE_STORAGE_SUCCESS The operation was successfully registered on the thread.
|
/// @retval SCE_REMOTE_STORAGE_SUCCESS
|
||||||
/// @retval SCE_REMOTE_STORAGE_ERROR_NOT_INITIALISED The RemoteStorage library was not initialised.
|
/// The operation was successfully registered on the thread.
|
||||||
/// @retval SCE_REMOTE_STORAGE_ERROR_FAILED_TO_ALLOCATE There is no enough memory on the library to perform an allocation.
|
/// @retval SCE_REMOTE_STORAGE_ERROR_NOT_INITIALISED The
|
||||||
/// @retval ERROR_OCCURRED This event will be sent to the event callback when an error has occurred in the thread.
|
/// RemoteStorage library was not initialised.
|
||||||
|
/// @retval SCE_REMOTE_STORAGE_ERROR_FAILED_TO_ALLOCATE There is no
|
||||||
|
/// enough memory on the library to perform an allocation.
|
||||||
|
/// @retval ERROR_OCCURRED
|
||||||
|
/// This event will be sent to the event callback when an error has occurred in
|
||||||
|
/// the thread.
|
||||||
///
|
///
|
||||||
/// @note System errors may be returned. Design your code so it does expect other errors.
|
/// @note System errors may be returned. Design your code so it does expect
|
||||||
int32_t sceRemoteStorageGetStatus(const SceRemoteStorageStatusReqParams & params, SceRemoteStorageStatus * status);
|
/// other errors.
|
||||||
|
int32_t sceRemoteStorageGetStatus(const SceRemoteStorageStatusReqParams& params,
|
||||||
|
SceRemoteStorageStatus* status);
|
||||||
|
|
||||||
/// @brief
|
/// @brief
|
||||||
/// Gets section of data from a file specified.
|
/// Gets section of data from a file specified.
|
||||||
///
|
///
|
||||||
/// Gets section of data from a file specified. The amount of data requested can be of any size. To request this information the name of file, the number of bytes and
|
/// Gets section of data from a file specified. The amount of data requested can
|
||||||
/// the byte to start reading along with a buffer to store such data must be provided.
|
/// be of any size. To request this information the name of file, the number of
|
||||||
/// Metadata information of the file, as description or visibility, will be provided only in the case the first amount of bytes for the file are requested (offset = 0).
|
/// bytes and the byte to start reading along with a buffer to store such data
|
||||||
/// This method does make use of the callback to inform the user of success termination. The SceRemoteStorageData pointer must be a pointer to a valid
|
/// must be provided. Metadata information of the file, as description or
|
||||||
/// location in memory until the callback is called as the output information will be stored in such location.
|
/// visibility, will be provided only in the case the first amount of bytes for
|
||||||
|
/// the file are requested (offset = 0). This method does make use of the
|
||||||
|
/// callback to inform the user of success termination. The SceRemoteStorageData
|
||||||
|
/// pointer must be a pointer to a valid location in memory until the callback
|
||||||
|
/// is called as the output information will be stored in such location.
|
||||||
///
|
///
|
||||||
/// @param params The structure containing the file name to read, the start byte to start reading and the amount of bytes to read.
|
/// @param params The structure containing the file name to read,
|
||||||
/// @param status The structure where the output information will be stored. The memory location being pointed must be valid until the callback gets called.
|
/// the start byte to start reading and the amount of bytes to read.
|
||||||
|
/// @param status The structure where the output information will
|
||||||
|
/// be stored. The memory location being pointed must be valid until the
|
||||||
|
/// callback gets called.
|
||||||
///
|
///
|
||||||
/// @retval SCE_REMOTE_STORAGE_SUCCESS The operation was successfully registered on the thread.
|
/// @retval SCE_REMOTE_STORAGE_SUCCESS
|
||||||
/// @retval SCE_REMOTE_STORAGE_ERROR_NOT_INITIALISED The RemoteStorage library was not initialised.
|
/// The operation was successfully registered on the thread.
|
||||||
/// @retval SCE_REMOTE_STORAGE_ERROR_FAILED_TO_ALLOCATE There is no enough memory on the library to perform an allocation.
|
/// @retval SCE_REMOTE_STORAGE_ERROR_NOT_INITIALISED The
|
||||||
/// @retval ERROR_OCCURRED This event will be sent to the event callback when an error has occurred in the thread.
|
/// RemoteStorage library was not initialised.
|
||||||
|
/// @retval SCE_REMOTE_STORAGE_ERROR_FAILED_TO_ALLOCATE There is no
|
||||||
|
/// enough memory on the library to perform an allocation.
|
||||||
|
/// @retval ERROR_OCCURRED
|
||||||
|
/// This event will be sent to the event callback when an error has occurred in
|
||||||
|
/// the thread.
|
||||||
///
|
///
|
||||||
/// @note System errors may be returned. Design your code so it does expect other errors.
|
/// @note System errors may be returned. Design your code so it does expect
|
||||||
int32_t sceRemoteStorageGetData(const SceRemoteStorageGetDataReqParams & params, SceRemoteStorageData * data);
|
/// other errors.
|
||||||
|
int32_t sceRemoteStorageGetData(const SceRemoteStorageGetDataReqParams& params,
|
||||||
|
SceRemoteStorageData* data);
|
||||||
|
|
||||||
/// @brief
|
/// @brief
|
||||||
/// Sets chunk of data to a file specified.
|
/// Sets chunk of data to a file specified.
|
||||||
///
|
///
|
||||||
/// Sets chunk of data to a file specified. The amount of data sent must be of, at least, 5 Megabytes per chunk excepts
|
/// Sets chunk of data to a file specified. The amount of data sent must be of,
|
||||||
/// in the case of the last chunk of the file (or the only one if that is the case) as it can be smaller.
|
/// at least, 5 Megabytes per chunk excepts in the case of the last chunk of the
|
||||||
/// The information provided regarding the chunk as the chunk number, total number of chunks, data buffer and its size should be provided in every call.
|
/// file (or the only one if that is the case) as it can be smaller. The
|
||||||
/// The information provided regarding the file as its name, description and visibility should be provided in the last chunk only (this is, when
|
/// information provided regarding the chunk as the chunk number, total number
|
||||||
/// chunk number = number of chunks).
|
/// of chunks, data buffer and its size should be provided in every call. The
|
||||||
/// This method does make use of the callback to inform the user of success termination. The data attribute of the SceRemoteStorageSetDataReqParams pointer
|
/// information provided regarding the file as its name, description and
|
||||||
/// must be a pointer to a valid location in memory until the callback is called as the buffer won't be copied internally.
|
/// visibility should be provided in the last chunk only (this is, when chunk
|
||||||
|
/// number = number of chunks). This method does make use of the callback to
|
||||||
|
/// inform the user of success termination. The data attribute of the
|
||||||
|
/// SceRemoteStorageSetDataReqParams pointer must be a pointer to a valid
|
||||||
|
/// location in memory until the callback is called as the buffer won't be
|
||||||
|
/// copied internally.
|
||||||
///
|
///
|
||||||
/// @param data The structure containing the chunk information.
|
/// @param data The structure containing the chunk information.
|
||||||
///
|
///
|
||||||
/// @retval SCE_REMOTE_STORAGE_SUCCESS The operation was successfully registered on the thread.
|
/// @retval SCE_REMOTE_STORAGE_SUCCESS
|
||||||
/// @retval SCE_REMOTE_STORAGE_ERROR_NOT_INITIALISED The RemoteStorage library was not initialised.
|
/// The operation was successfully registered on the thread.
|
||||||
/// @retval SCE_REMOTE_STORAGE_ERROR_FAILED_TO_ALLOCATE There is no enough memory on the library to perform an allocation.
|
/// @retval SCE_REMOTE_STORAGE_ERROR_NOT_INITIALISED The
|
||||||
/// @retval ERROR_OCCURRED This event will be sent to the event callback when an error has occurred in the thread.
|
/// RemoteStorage library was not initialised.
|
||||||
|
/// @retval SCE_REMOTE_STORAGE_ERROR_FAILED_TO_ALLOCATE There is no
|
||||||
|
/// enough memory on the library to perform an allocation.
|
||||||
|
/// @retval ERROR_OCCURRED
|
||||||
|
/// This event will be sent to the event callback when an error has occurred in
|
||||||
|
/// the thread.
|
||||||
///
|
///
|
||||||
/// @note System errors may be returned. Design your code so it does expect other errors.
|
/// @note System errors may be returned. Design your code so it does expect
|
||||||
int32_t sceRemoteStorageSetData(const SceRemoteStorageSetDataReqParams & data);
|
/// other errors.
|
||||||
|
int32_t sceRemoteStorageSetData(const SceRemoteStorageSetDataReqParams& data);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
@ -15,153 +15,201 @@
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
|
|
||||||
// Macros
|
// Macros
|
||||||
#define SCE_REMOTE_STORAGE_MAX_FILES 16
|
#define SCE_REMOTE_STORAGE_MAX_FILES 16
|
||||||
#define SCE_REMOTE_STORAGE_DATA_NAME_MAX_LEN 64
|
#define SCE_REMOTE_STORAGE_DATA_NAME_MAX_LEN 64
|
||||||
#define SCE_REMOTE_STORAGE_CLIENT_ID_MAX_LEN 64
|
#define SCE_REMOTE_STORAGE_CLIENT_ID_MAX_LEN 64
|
||||||
#define SCE_REMOTE_STORAGE_PLATFORM_NAME_MAX_LEN 16
|
#define SCE_REMOTE_STORAGE_PLATFORM_NAME_MAX_LEN 16
|
||||||
#define SCE_REMOTE_STORAGE_MD5_STRING_LENGTH 33
|
#define SCE_REMOTE_STORAGE_MD5_STRING_LENGTH 33
|
||||||
#define SCE_REMOTE_STORAGE_RFC2822_LENGTH 32
|
#define SCE_REMOTE_STORAGE_RFC2822_LENGTH 32
|
||||||
#define SCE_REMOTE_STORAGE_DATA_DESCRIPTION_MAX_LEN 256
|
#define SCE_REMOTE_STORAGE_DATA_DESCRIPTION_MAX_LEN 256
|
||||||
#define SCE_REMOTE_STORAGE_DATA_LOCATION_MAX_LEN 256
|
#define SCE_REMOTE_STORAGE_DATA_LOCATION_MAX_LEN 256
|
||||||
#define SCE_REMOTE_STORAGE_PS3_SAVEDATA_SECUREFILEID_SIZE 16
|
#define SCE_REMOTE_STORAGE_PS3_SAVEDATA_SECUREFILEID_SIZE 16
|
||||||
#define SCE_REMOTE_STORAGE_PS3_SAVEDATA_FILENAME_SIZE 13
|
#define SCE_REMOTE_STORAGE_PS3_SAVEDATA_FILENAME_SIZE 13
|
||||||
#define SCE_REMOTE_STORAGE_AUTH_CODE_MAX_LEN 128
|
#define SCE_REMOTE_STORAGE_AUTH_CODE_MAX_LEN 128
|
||||||
|
|
||||||
// Return values
|
// Return values
|
||||||
#define SCE_REMOTE_STORAGE_SUCCESS 0
|
#define SCE_REMOTE_STORAGE_SUCCESS 0
|
||||||
|
|
||||||
// Error codes
|
// Error codes
|
||||||
#define SCE_REMOTE_STORAGE_ERROR_INVALID_ARGUMENT 0x80001001
|
#define SCE_REMOTE_STORAGE_ERROR_INVALID_ARGUMENT 0x80001001
|
||||||
#define SCE_REMOTE_STORAGE_ERROR_FAILED_TO_CREATE_THREAD 0x80001002
|
#define SCE_REMOTE_STORAGE_ERROR_FAILED_TO_CREATE_THREAD 0x80001002
|
||||||
#define SCE_REMOTE_STORAGE_ERROR_NOT_INITIALISED 0x80001003
|
#define SCE_REMOTE_STORAGE_ERROR_NOT_INITIALISED 0x80001003
|
||||||
#define SCE_REMOTE_STORAGE_ERROR_FAILED_TO_OPEN_WEB_BROWSER 0x80001004
|
#define SCE_REMOTE_STORAGE_ERROR_FAILED_TO_OPEN_WEB_BROWSER 0x80001004
|
||||||
#define SCE_REMOTE_STORAGE_ERROR_PSN_ACCOUNT_NOT_LINKED 0x80001005
|
#define SCE_REMOTE_STORAGE_ERROR_PSN_ACCOUNT_NOT_LINKED 0x80001005
|
||||||
#define SCE_REMOTE_STORAGE_ERROR_COULD_NOT_CREATE_SESSION 0x80001006
|
#define SCE_REMOTE_STORAGE_ERROR_COULD_NOT_CREATE_SESSION 0x80001006
|
||||||
#define SCE_REMOTE_STORAGE_ERROR_FAILED_TO_ALLOCATE 0x80001007
|
#define SCE_REMOTE_STORAGE_ERROR_FAILED_TO_ALLOCATE 0x80001007
|
||||||
#define SCE_REMOTE_STORAGE_ERROR_SESSION_DOES_NOT_EXIST 0x80001008
|
#define SCE_REMOTE_STORAGE_ERROR_SESSION_DOES_NOT_EXIST 0x80001008
|
||||||
#define SCE_REMOTE_STORAGE_ERROR_REQ_ID_NOT_FOUND 0x80001009
|
#define SCE_REMOTE_STORAGE_ERROR_REQ_ID_NOT_FOUND 0x80001009
|
||||||
#define SCE_REMOTE_STORAGE_ERROR_MAX_NUMBER_FILES_REACHED 0x8000100A
|
#define SCE_REMOTE_STORAGE_ERROR_MAX_NUMBER_FILES_REACHED 0x8000100A
|
||||||
#define SCE_REMOTE_STORAGE_ERROR_NO_MORE_SYNCS 0x8000100B
|
#define SCE_REMOTE_STORAGE_ERROR_NO_MORE_SYNCS 0x8000100B
|
||||||
#define SCE_REMOTE_STORAGE_ERROR_ALREADY_INITIALISED 0x8000100C
|
#define SCE_REMOTE_STORAGE_ERROR_ALREADY_INITIALISED 0x8000100C
|
||||||
#define SCE_REMOTE_STORAGE_ERROR_INVALID_UPLOADID 0x8000100D
|
#define SCE_REMOTE_STORAGE_ERROR_INVALID_UPLOADID 0x8000100D
|
||||||
#define SCE_REMOTE_STORAGE_ERROR_FAILED_TO_OPEN_FILE 0x8000100E
|
#define SCE_REMOTE_STORAGE_ERROR_FAILED_TO_OPEN_FILE 0x8000100E
|
||||||
#define SCE_REMOTE_STORAGE_ERROR_CLOUD_DATA_CORRUPTED 0x8000100F
|
#define SCE_REMOTE_STORAGE_ERROR_CLOUD_DATA_CORRUPTED 0x8000100F
|
||||||
#define SCE_REMOTE_STORAGE_ERROR_INVALID_CHAR_IN_FILE_NAME 0x80001010
|
#define SCE_REMOTE_STORAGE_ERROR_INVALID_CHAR_IN_FILE_NAME 0x80001010
|
||||||
#define SCE_REMOTE_STORAGE_ERROR_INVALID_JSON_RESPONSE 0x80001011
|
#define SCE_REMOTE_STORAGE_ERROR_INVALID_JSON_RESPONSE 0x80001011
|
||||||
#define SCE_REMOTE_STORAGE_ERROR_REQUEST_ABORTED 0x80001012
|
#define SCE_REMOTE_STORAGE_ERROR_REQUEST_ABORTED 0x80001012
|
||||||
#define SCE_REMOTE_STORAGE_ERROR_SERVER_ERROR 0x80002000 // Server errors can be between 0x80002064 to 0x800022BB both included
|
#define SCE_REMOTE_STORAGE_ERROR_SERVER_ERROR \
|
||||||
|
0x80002000 // Server errors can be between 0x80002064 to 0x800022BB both
|
||||||
|
// included
|
||||||
|
|
||||||
|
typedef enum SceRemoteStorageDataVisibility {
|
||||||
typedef enum SceRemoteStorageDataVisibility
|
PRIVATE = 0, // Only data owner can read and write data
|
||||||
{
|
PUBLIC_READ_ONLY, // Everyone can read this data. Owner can write to it
|
||||||
PRIVATE = 0, // Only data owner can read and write data
|
PUBLIC_READ_WRITE // Everyone can read and write data
|
||||||
PUBLIC_READ_ONLY, // Everyone can read this data. Owner can write to it
|
|
||||||
PUBLIC_READ_WRITE // Everyone can read and write data
|
|
||||||
} SceRemoteStorageDataVisibility;
|
} SceRemoteStorageDataVisibility;
|
||||||
|
|
||||||
typedef enum SceRemoteStorageEvent
|
typedef enum SceRemoteStorageEvent {
|
||||||
{
|
USER_ACCOUNT_LINKED = 0, // User's account has been linked with PSN
|
||||||
USER_ACCOUNT_LINKED = 0, // User's account has been linked with PSN
|
PSN_SIGN_IN_REQUIRED, // User's PSN sign-in through web browser is required
|
||||||
PSN_SIGN_IN_REQUIRED, // User's PSN sign-in through web browser is required
|
WEB_BROWSER_RESULT, // Result of sceRemoteStorageOpenWebBrowser(). Please
|
||||||
WEB_BROWSER_RESULT, // Result of sceRemoteStorageOpenWebBrowser(). Please check retCode
|
// check retCode
|
||||||
GET_DATA_RESULT, // Result of sceRemoteStorageGetData(). Please check retCode
|
GET_DATA_RESULT, // Result of sceRemoteStorageGetData(). Please check
|
||||||
GET_DATA_PROGRESS, // Progress of sceRemoteStorageGetData() completion as a percentage. Please check retCode
|
// retCode
|
||||||
SET_DATA_RESULT, // Result of sceRemoteStorageSetData(). Please check retCode
|
GET_DATA_PROGRESS, // Progress of sceRemoteStorageGetData() completion as a
|
||||||
SET_DATA_PROGRESS, // Progress of sceRemoteStorageSetData() completion as a percentage. Please check retCode
|
// percentage. Please check retCode
|
||||||
GET_STATUS_RESULT, // Result of sceRemoteStorageGetStatus(). Please check retCode
|
SET_DATA_RESULT, // Result of sceRemoteStorageSetData(). Please check
|
||||||
ERROR_OCCURRED // A generic error has occurred. Please check retCode
|
// retCode
|
||||||
|
SET_DATA_PROGRESS, // Progress of sceRemoteStorageSetData() completion as a
|
||||||
|
// percentage. Please check retCode
|
||||||
|
GET_STATUS_RESULT, // Result of sceRemoteStorageGetStatus(). Please check
|
||||||
|
// retCode
|
||||||
|
ERROR_OCCURRED // A generic error has occurred. Please check retCode
|
||||||
} SceRemoteStorageEvent;
|
} SceRemoteStorageEvent;
|
||||||
|
|
||||||
typedef enum SceRemoteStorageEnvironment
|
typedef enum SceRemoteStorageEnvironment {
|
||||||
{
|
DEVELOPMENT = 0,
|
||||||
DEVELOPMENT = 0,
|
PRODUCTION
|
||||||
PRODUCTION
|
} SceRemoteStorageEnvironment;
|
||||||
}SceRemoteStorageEnvironment;
|
|
||||||
|
|
||||||
typedef void (*sceRemoteStorageCallback)(const SceRemoteStorageEvent event, int32_t retCode, void * userData);
|
typedef void (*sceRemoteStorageCallback)(const SceRemoteStorageEvent event,
|
||||||
|
int32_t retCode, void* userData);
|
||||||
|
|
||||||
typedef struct SceRemoteStorageInitParamsThread
|
typedef struct SceRemoteStorageInitParamsThread {
|
||||||
{
|
int32_t threadAffinity; // Thread affinity
|
||||||
int32_t threadAffinity; // Thread affinity
|
int32_t threadPriority; // Priority that the thread runs out
|
||||||
int32_t threadPriority; // Priority that the thread runs out
|
|
||||||
} SceRemoteStorageInitParamsThread;
|
} SceRemoteStorageInitParamsThread;
|
||||||
|
|
||||||
typedef struct SceRemoteStorageInitParamsPool
|
typedef struct SceRemoteStorageInitParamsPool {
|
||||||
{
|
void* memPoolBuffer; // Memory pool used by sceRemoteStorage library
|
||||||
void * memPoolBuffer; // Memory pool used by sceRemoteStorage library
|
size_t memPoolSize; // Size of memPoolBuffer
|
||||||
size_t memPoolSize; // Size of memPoolBuffer
|
|
||||||
} SceRemoteStorageInitParamsPool;
|
} SceRemoteStorageInitParamsPool;
|
||||||
|
|
||||||
typedef struct SceRemoteStorageInitTimeout
|
typedef struct SceRemoteStorageInitTimeout {
|
||||||
{
|
uint32_t resolveMs; // Timeout for DNS resolution in milliseconds. Defaults
|
||||||
uint32_t resolveMs; //Timeout for DNS resolution in milliseconds. Defaults to 30 seconds
|
// to 30 seconds
|
||||||
uint32_t connectMs; //Timeout for first connection between client and server. Defaults to 30 seconds
|
uint32_t connectMs; // Timeout for first connection between client and
|
||||||
uint32_t sendMs; //Timeout to send request to server. Defaults to 120 seconds
|
// server. Defaults to 30 seconds
|
||||||
uint32_t receiveMs; //Timeout to receive information from server. Defaults to 120 seconds
|
uint32_t
|
||||||
|
sendMs; // Timeout to send request to server. Defaults to 120 seconds
|
||||||
SceRemoteStorageInitTimeout() : resolveMs(30 * 1000), connectMs(30 * 1000), sendMs(120 * 1000), receiveMs(120 * 1000) {}
|
uint32_t receiveMs; // Timeout to receive information from server. Defaults
|
||||||
}SceRemoteStorageInitTimeout;
|
// to 120 seconds
|
||||||
|
|
||||||
typedef struct SceRemoteStorageInitParams
|
SceRemoteStorageInitTimeout()
|
||||||
{
|
: resolveMs(30 * 1000),
|
||||||
sceRemoteStorageCallback callback; // Event callback
|
connectMs(30 * 1000),
|
||||||
void * userData; // Application defined data for callback
|
sendMs(120 * 1000),
|
||||||
int32_t httpContextId; // PS4 only: Http context ID that was returned from sceHttpInit()
|
receiveMs(120 * 1000) {}
|
||||||
int32_t userId; // PS4 only: Current user, see SceUserServiceUserId
|
} SceRemoteStorageInitTimeout;
|
||||||
void * psnTicket; // PS3 only: The PSN ticket used to authenticate the user
|
|
||||||
size_t psnTicketSize; // PS3 only: The size of the PSN ticket in bytes
|
typedef struct SceRemoteStorageInitParams {
|
||||||
char clientId[SCE_REMOTE_STORAGE_CLIENT_ID_MAX_LEN]; // This represents your application on PSN, used to sign PSN user in for your title
|
sceRemoteStorageCallback callback; // Event callback
|
||||||
SceRemoteStorageInitTimeout timeout; // Timeout for network transactions
|
void* userData; // Application defined data for callback
|
||||||
SceRemoteStorageInitParamsPool pool; // Memory pool parameters
|
int32_t httpContextId; // PS4 only: Http context ID that was returned from
|
||||||
SceRemoteStorageInitParamsThread thread; // Thread creation parameters
|
// sceHttpInit()
|
||||||
SceRemoteStorageEnvironment environment; // Only used on non-PlayStation platforms: PSN Environment used by the library
|
int32_t userId; // PS4 only: Current user, see SceUserServiceUserId
|
||||||
|
void* psnTicket; // PS3 only: The PSN ticket used to authenticate the user
|
||||||
|
size_t psnTicketSize; // PS3 only: The size of the PSN ticket in bytes
|
||||||
|
char clientId[SCE_REMOTE_STORAGE_CLIENT_ID_MAX_LEN]; // This represents
|
||||||
|
// your application on
|
||||||
|
// PSN, used to sign
|
||||||
|
// PSN user in for
|
||||||
|
// your title
|
||||||
|
SceRemoteStorageInitTimeout timeout; // Timeout for network transactions
|
||||||
|
SceRemoteStorageInitParamsPool pool; // Memory pool parameters
|
||||||
|
SceRemoteStorageInitParamsThread thread; // Thread creation parameters
|
||||||
|
SceRemoteStorageEnvironment
|
||||||
|
environment; // Only used on non-PlayStation platforms: PSN Environment
|
||||||
|
// used by the library
|
||||||
} SceRemoteStorageInitParams;
|
} SceRemoteStorageInitParams;
|
||||||
|
|
||||||
typedef struct SceRemoteStorageGetDataReqParams
|
typedef struct SceRemoteStorageGetDataReqParams {
|
||||||
{
|
char fileName[SCE_REMOTE_STORAGE_DATA_NAME_MAX_LEN]; // Name of file on
|
||||||
char fileName[SCE_REMOTE_STORAGE_DATA_NAME_MAX_LEN]; // Name of file on remote storage server
|
// remote storage
|
||||||
char pathLocation[SCE_REMOTE_STORAGE_DATA_LOCATION_MAX_LEN]; // File location on the HDD
|
// server
|
||||||
char secureFileId[SCE_REMOTE_STORAGE_PS3_SAVEDATA_SECUREFILEID_SIZE]; // PS3 only. ID used for save data encryption
|
char pathLocation
|
||||||
char ps3DataFilename[SCE_REMOTE_STORAGE_PS3_SAVEDATA_FILENAME_SIZE]; // PS3 only. Name of data file in save data
|
[SCE_REMOTE_STORAGE_DATA_LOCATION_MAX_LEN]; // File location on the HDD
|
||||||
uint32_t ps3FileType; // PS3 only. Type of file, CELL_SAVEDATA_FILETYPE_XXX
|
char secureFileId
|
||||||
SceAppUtilSaveDataDataSlot psVitaSaveDataSlot; // PS Vita only. Save data slot information
|
[SCE_REMOTE_STORAGE_PS3_SAVEDATA_SECUREFILEID_SIZE]; // PS3 only. ID
|
||||||
|
// used for save
|
||||||
|
// data encryption
|
||||||
|
char ps3DataFilename
|
||||||
|
[SCE_REMOTE_STORAGE_PS3_SAVEDATA_FILENAME_SIZE]; // PS3 only. Name of
|
||||||
|
// data file in save
|
||||||
|
// data
|
||||||
|
uint32_t ps3FileType; // PS3 only. Type of file, CELL_SAVEDATA_FILETYPE_XXX
|
||||||
|
SceAppUtilSaveDataDataSlot
|
||||||
|
psVitaSaveDataSlot; // PS Vita only. Save data slot information
|
||||||
} SceRemoteStorageGetDataReqParams;
|
} SceRemoteStorageGetDataReqParams;
|
||||||
|
|
||||||
typedef struct SceRemoteStorageSetDataReqParams
|
typedef struct SceRemoteStorageSetDataReqParams {
|
||||||
{
|
char fileName[SCE_REMOTE_STORAGE_DATA_NAME_MAX_LEN]; // Name of file on
|
||||||
char fileName[SCE_REMOTE_STORAGE_DATA_NAME_MAX_LEN]; // Name of file on remote storage server
|
// remote storage
|
||||||
char fileDescription[SCE_REMOTE_STORAGE_DATA_DESCRIPTION_MAX_LEN]; // Description of file on remote storage server
|
// server
|
||||||
char pathLocation[SCE_REMOTE_STORAGE_DATA_LOCATION_MAX_LEN]; // File location on the HDD
|
char fileDescription
|
||||||
char secureFileId[SCE_REMOTE_STORAGE_PS3_SAVEDATA_SECUREFILEID_SIZE]; // PS3 only. ID used for save data encryption
|
[SCE_REMOTE_STORAGE_DATA_DESCRIPTION_MAX_LEN]; // Description of file
|
||||||
char ps3DataFilename[SCE_REMOTE_STORAGE_PS3_SAVEDATA_FILENAME_SIZE]; // PS3 only. Name of data file in save data
|
// on remote storage
|
||||||
uint32_t ps3FileType; // PS3 only. Type of file, CELL_SAVEDATA_FILETYPE_XXX
|
// server
|
||||||
SceRemoteStorageDataVisibility visibility; // Visibility of data
|
char pathLocation
|
||||||
|
[SCE_REMOTE_STORAGE_DATA_LOCATION_MAX_LEN]; // File location on the HDD
|
||||||
|
char secureFileId
|
||||||
|
[SCE_REMOTE_STORAGE_PS3_SAVEDATA_SECUREFILEID_SIZE]; // PS3 only. ID
|
||||||
|
// used for save
|
||||||
|
// data encryption
|
||||||
|
char ps3DataFilename
|
||||||
|
[SCE_REMOTE_STORAGE_PS3_SAVEDATA_FILENAME_SIZE]; // PS3 only. Name of
|
||||||
|
// data file in save
|
||||||
|
// data
|
||||||
|
uint32_t ps3FileType; // PS3 only. Type of file, CELL_SAVEDATA_FILETYPE_XXX
|
||||||
|
SceRemoteStorageDataVisibility visibility; // Visibility of data
|
||||||
} SceRemoteStorageSetDataReqParams;
|
} SceRemoteStorageSetDataReqParams;
|
||||||
|
|
||||||
typedef struct SceRemoteStorageData
|
typedef struct SceRemoteStorageData {
|
||||||
{
|
char fileName[SCE_REMOTE_STORAGE_DATA_NAME_MAX_LEN]; // Name of file on
|
||||||
char fileName[SCE_REMOTE_STORAGE_DATA_NAME_MAX_LEN]; // Name of file on remote storage server
|
// remote storage
|
||||||
char fileDescription[SCE_REMOTE_STORAGE_DATA_DESCRIPTION_MAX_LEN]; // Description of file on remote storage server
|
// server
|
||||||
size_t fileSize; // Size of file in bytes
|
char fileDescription
|
||||||
char md5Checksum[SCE_REMOTE_STORAGE_MD5_STRING_LENGTH]; // File MD5 checksum
|
[SCE_REMOTE_STORAGE_DATA_DESCRIPTION_MAX_LEN]; // Description of file
|
||||||
char timeStamp[SCE_REMOTE_STORAGE_RFC2822_LENGTH]; // Time that data was written on the server. Format is RFC2822
|
// on remote storage
|
||||||
SceRemoteStorageDataVisibility visibility; // Visibility of data
|
// server
|
||||||
|
size_t fileSize; // Size of file in bytes
|
||||||
|
char
|
||||||
|
md5Checksum[SCE_REMOTE_STORAGE_MD5_STRING_LENGTH]; // File MD5 checksum
|
||||||
|
char
|
||||||
|
timeStamp[SCE_REMOTE_STORAGE_RFC2822_LENGTH]; // Time that data was
|
||||||
|
// written on the server.
|
||||||
|
// Format is RFC2822
|
||||||
|
SceRemoteStorageDataVisibility visibility; // Visibility of data
|
||||||
} SceRemoteStorageData;
|
} SceRemoteStorageData;
|
||||||
|
|
||||||
typedef struct SceRemoteStorageWebBrowserReqParams { } SceRemoteStorageWebBrowseReqParams;
|
typedef struct SceRemoteStorageWebBrowserReqParams {
|
||||||
|
} SceRemoteStorageWebBrowseReqParams;
|
||||||
|
|
||||||
typedef struct SceRemoteStorageStatusReqParams { } SceRemoteStorageStatusReqParams;
|
typedef struct SceRemoteStorageStatusReqParams {
|
||||||
|
} SceRemoteStorageStatusReqParams;
|
||||||
|
|
||||||
typedef struct SceRemoteStorageAbortReqParams
|
typedef struct SceRemoteStorageAbortReqParams {
|
||||||
{
|
uint32_t requestId; // The request Id to be aborted
|
||||||
uint32_t requestId; // The request Id to be aborted
|
|
||||||
} SceRemoteStorageAbortReqParams;
|
} SceRemoteStorageAbortReqParams;
|
||||||
|
|
||||||
typedef struct SceRemoteStorageStatus
|
typedef struct SceRemoteStorageStatus {
|
||||||
{
|
uint32_t numFiles; // Number of files user has on remote storage server
|
||||||
uint32_t numFiles; // Number of files user has on remote storage server
|
SceRemoteStorageData
|
||||||
SceRemoteStorageData data[SCE_REMOTE_STORAGE_MAX_FILES]; // Details about data if available. Data buffer will not be retrieved
|
data[SCE_REMOTE_STORAGE_MAX_FILES]; // Details about data if available.
|
||||||
uint64_t remainingSyncs; // Remaining syncs. the user has for upload/download
|
// Data buffer will not be
|
||||||
|
// retrieved
|
||||||
|
uint64_t
|
||||||
|
remainingSyncs; // Remaining syncs. the user has for upload/download
|
||||||
} SceRemoteStorageStatus;
|
} SceRemoteStorageStatus;
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue