mirror of
https://github.com/4jcraft/4jcraft.git
synced 2026-05-10 10:37:14 +00:00
remove LeaderboardInterface, LeaderboardManager, LinuxLeaderboardManager, for StubLeaderboard
This commit is contained in:
parent
d3a9de8b2a
commit
a71b1036c7
|
|
@ -1,100 +0,0 @@
|
|||
#include "LeaderboardInterface.h"
|
||||
|
||||
#include <assert.h>
|
||||
|
||||
#include "app/common/Leaderboards/LeaderboardManager.h"
|
||||
|
||||
LeaderboardInterface::LeaderboardInterface(IPlatformLeaderboard* man) {
|
||||
m_manager = man;
|
||||
m_pending = false;
|
||||
|
||||
m_filter = (IPlatformLeaderboard::EFilterMode)-1;
|
||||
m_callback = nullptr;
|
||||
m_difficulty = 0;
|
||||
m_type = IPlatformLeaderboard::eStatsType_UNDEFINED;
|
||||
m_startIndex = 0;
|
||||
m_readCount = 0;
|
||||
|
||||
(void)m_manager->OpenSession();
|
||||
}
|
||||
|
||||
LeaderboardInterface::~LeaderboardInterface() {
|
||||
m_manager->CancelOperation();
|
||||
m_manager->CloseSession();
|
||||
}
|
||||
|
||||
void LeaderboardInterface::ReadStats_Friends(
|
||||
LeaderboardReadListener* callback, int difficulty,
|
||||
IPlatformLeaderboard::EStatsType type, PlayerUID myUID,
|
||||
unsigned int startIndex, unsigned int readCount) {
|
||||
m_filter = IPlatformLeaderboard::eFM_Friends;
|
||||
m_pending = true;
|
||||
|
||||
m_callback = callback;
|
||||
m_difficulty = difficulty;
|
||||
m_type = type;
|
||||
m_myUID = myUID;
|
||||
m_startIndex = startIndex;
|
||||
m_readCount = readCount;
|
||||
|
||||
tick();
|
||||
}
|
||||
|
||||
void LeaderboardInterface::ReadStats_MyScore(
|
||||
LeaderboardReadListener* callback, int difficulty,
|
||||
IPlatformLeaderboard::EStatsType type, PlayerUID myUID,
|
||||
unsigned int readCount) {
|
||||
m_filter = IPlatformLeaderboard::eFM_MyScore;
|
||||
m_pending = true;
|
||||
|
||||
m_callback = callback;
|
||||
m_difficulty = difficulty;
|
||||
m_type = type;
|
||||
m_myUID = myUID;
|
||||
m_readCount = readCount;
|
||||
|
||||
tick();
|
||||
}
|
||||
|
||||
void LeaderboardInterface::ReadStats_TopRank(
|
||||
LeaderboardReadListener* callback, int difficulty,
|
||||
IPlatformLeaderboard::EStatsType type, unsigned int startIndex,
|
||||
unsigned int readCount) {
|
||||
m_filter = IPlatformLeaderboard::eFM_TopRank;
|
||||
m_pending = true;
|
||||
|
||||
m_callback = callback;
|
||||
m_difficulty = difficulty;
|
||||
m_type = type;
|
||||
m_startIndex = startIndex;
|
||||
m_readCount = readCount;
|
||||
|
||||
tick();
|
||||
}
|
||||
|
||||
void LeaderboardInterface::CancelOperation() {
|
||||
m_manager->CancelOperation();
|
||||
m_pending = false;
|
||||
}
|
||||
|
||||
void LeaderboardInterface::tick() {
|
||||
if (m_pending) m_pending = !callManager();
|
||||
}
|
||||
|
||||
bool LeaderboardInterface::callManager() {
|
||||
switch (m_filter) {
|
||||
case IPlatformLeaderboard::eFM_Friends:
|
||||
return m_manager->ReadStats_Friends(m_callback, m_difficulty,
|
||||
m_type, m_myUID, m_startIndex,
|
||||
m_readCount);
|
||||
case IPlatformLeaderboard::eFM_MyScore:
|
||||
return m_manager->ReadStats_MyScore(m_callback, m_difficulty,
|
||||
m_type, m_myUID, m_readCount);
|
||||
case IPlatformLeaderboard::eFM_TopRank:
|
||||
return m_manager->ReadStats_TopRank(
|
||||
m_callback, m_difficulty, m_type, m_startIndex, m_readCount);
|
||||
default:
|
||||
assert(false);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
|
@ -1,42 +0,0 @@
|
|||
#pragma once
|
||||
|
||||
#include "LeaderboardManager.h"
|
||||
#include "platform/PlatformTypes.h"
|
||||
|
||||
// 4J-JEV: Simple interface for handling ReadStat failures.
|
||||
class LeaderboardInterface {
|
||||
private:
|
||||
IPlatformLeaderboard* m_manager;
|
||||
bool m_pending;
|
||||
|
||||
// Arguments.
|
||||
IPlatformLeaderboard::EFilterMode m_filter;
|
||||
LeaderboardReadListener* m_callback;
|
||||
int m_difficulty;
|
||||
IPlatformLeaderboard::EStatsType m_type;
|
||||
PlayerUID m_myUID;
|
||||
unsigned int m_startIndex;
|
||||
unsigned int m_readCount;
|
||||
|
||||
public:
|
||||
LeaderboardInterface(IPlatformLeaderboard* man);
|
||||
~LeaderboardInterface();
|
||||
|
||||
void ReadStats_Friends(LeaderboardReadListener* callback, int difficulty,
|
||||
IPlatformLeaderboard::EStatsType type,
|
||||
PlayerUID myUID, unsigned int startIndex,
|
||||
unsigned int readCount);
|
||||
void ReadStats_MyScore(LeaderboardReadListener* callback, int difficulty,
|
||||
IPlatformLeaderboard::EStatsType type,
|
||||
PlayerUID myUID, unsigned int readCount);
|
||||
void ReadStats_TopRank(LeaderboardReadListener* callback, int difficulty,
|
||||
IPlatformLeaderboard::EStatsType type,
|
||||
unsigned int startIndex, unsigned int readCount);
|
||||
|
||||
void CancelOperation();
|
||||
|
||||
void tick();
|
||||
|
||||
private:
|
||||
bool callManager();
|
||||
};
|
||||
|
|
@ -1,106 +0,0 @@
|
|||
#include "LeaderboardManager.h"
|
||||
|
||||
#include "app/linux/LinuxGame.h"
|
||||
#include "util/StringHelpers.h"
|
||||
|
||||
const std::string LeaderboardManager::filterNames[eNumFilterModes] = {
|
||||
"Friends", "MyScore", "TopRank"};
|
||||
|
||||
void LeaderboardManager::DeleteInstance() {
|
||||
delete m_instance;
|
||||
m_instance = nullptr;
|
||||
}
|
||||
|
||||
LeaderboardManager::LeaderboardManager() {
|
||||
zeroReadParameters();
|
||||
|
||||
m_myXUID = INVALID_XUID;
|
||||
}
|
||||
|
||||
void LeaderboardManager::zeroReadParameters() {
|
||||
m_difficulty = -1;
|
||||
m_statsType = eStatsType_UNDEFINED;
|
||||
m_readListener = nullptr;
|
||||
m_startIndex = 0;
|
||||
m_readCount = 0;
|
||||
m_eFilterMode = eFM_UNDEFINED;
|
||||
}
|
||||
|
||||
bool LeaderboardManager::ReadStats_Friends(LeaderboardReadListener* listener,
|
||||
int difficulty, EStatsType type,
|
||||
PlayerUID myUID,
|
||||
unsigned int startIndex,
|
||||
unsigned int readCount) {
|
||||
zeroReadParameters();
|
||||
|
||||
m_readListener = listener;
|
||||
m_difficulty = difficulty;
|
||||
m_statsType = type;
|
||||
|
||||
m_eFilterMode = eFM_Friends;
|
||||
return true;
|
||||
}
|
||||
|
||||
bool LeaderboardManager::ReadStats_MyScore(LeaderboardReadListener* listener,
|
||||
int difficulty, EStatsType type,
|
||||
PlayerUID myUID,
|
||||
unsigned int readCount) {
|
||||
zeroReadParameters();
|
||||
|
||||
m_readListener = listener;
|
||||
m_difficulty = difficulty;
|
||||
m_statsType = type;
|
||||
|
||||
m_readCount = readCount;
|
||||
|
||||
m_eFilterMode = eFM_MyScore;
|
||||
return true;
|
||||
}
|
||||
|
||||
bool LeaderboardManager::ReadStats_TopRank(LeaderboardReadListener* listener,
|
||||
int difficulty, EStatsType type,
|
||||
unsigned int startIndex,
|
||||
unsigned int readCount) {
|
||||
zeroReadParameters();
|
||||
|
||||
m_readListener = listener;
|
||||
m_difficulty = difficulty;
|
||||
m_statsType = type;
|
||||
|
||||
m_startIndex = startIndex;
|
||||
m_readCount = readCount;
|
||||
|
||||
m_eFilterMode = eFM_TopRank;
|
||||
return true;
|
||||
}
|
||||
|
||||
void LeaderboardManager::printStats(ReadView& view) {
|
||||
app.DebugPrintf(
|
||||
"[LeaderboardManager] Printing stats:\n"
|
||||
"\tnumQueries=%i\n",
|
||||
view.m_numQueries);
|
||||
|
||||
for (unsigned int i = 0; i < view.m_numQueries; i++) {
|
||||
ReadScore score = view.m_queries[i];
|
||||
|
||||
app.DebugPrintf("\tname='%s'\n", score.m_name.c_str());
|
||||
app.DebugPrintf("\trank='%i'\n", score.m_rank);
|
||||
|
||||
app.DebugPrintf("\tstatsData=[");
|
||||
for (int j = 0; j < score.m_statsSize; j++)
|
||||
app.DebugPrintf(" %i", score.m_statsData[j]);
|
||||
app.DebugPrintf("]\n");
|
||||
}
|
||||
}
|
||||
|
||||
bool DebugReadListener::OnStatsReadComplete(
|
||||
IPlatformLeaderboard::eStatsReturn success, int numResults,
|
||||
IPlatformLeaderboard::ViewOut results) {
|
||||
app.DebugPrintf("[DebugReadListener] OnStatsReadComplete, %s:\n",
|
||||
(success ? "success" : "FAILED"));
|
||||
LeaderboardManager::printStats(results);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
DebugReadListener* DebugReadListener::m_instance = new DebugReadListener();
|
||||
|
|
@ -1,56 +0,0 @@
|
|||
#pragma once
|
||||
|
||||
#include <string>
|
||||
|
||||
#include "platform/leaderboard/IPlatformLeaderboard.h"
|
||||
|
||||
class LeaderboardManager : public IPlatformLeaderboard {
|
||||
public:
|
||||
static const std::string filterNames[eNumFilterModes];
|
||||
|
||||
LeaderboardManager();
|
||||
virtual ~LeaderboardManager() {}
|
||||
|
||||
// Singleton
|
||||
static IPlatformLeaderboard* Instance() { return m_instance; }
|
||||
static void DeleteInstance();
|
||||
|
||||
// IPlatformLeaderboard pure virtuals - subclasses must implement:
|
||||
// Tick, OpenSession, CloseSession, DeleteSession, WriteStats,
|
||||
// FlushStats, CancelOperation, isIdle
|
||||
|
||||
// Base implementations for read operations
|
||||
bool ReadStats_Friends(LeaderboardReadListener* callback, int difficulty,
|
||||
EStatsType type, PlayerUID myUID,
|
||||
unsigned int startIndex,
|
||||
unsigned int readCount) override;
|
||||
bool ReadStats_MyScore(LeaderboardReadListener* callback, int difficulty,
|
||||
EStatsType type, PlayerUID myUID,
|
||||
unsigned int readCount) override;
|
||||
bool ReadStats_TopRank(LeaderboardReadListener* callback, int difficulty,
|
||||
EStatsType type, unsigned int startIndex,
|
||||
unsigned int readCount) override;
|
||||
|
||||
static void printStats(ReadView& view);
|
||||
|
||||
protected:
|
||||
virtual void zeroReadParameters();
|
||||
|
||||
EFilterMode m_eFilterMode;
|
||||
int m_difficulty;
|
||||
EStatsType m_statsType;
|
||||
LeaderboardReadListener* m_readListener;
|
||||
PlayerUID m_myXUID;
|
||||
unsigned int m_startIndex, m_readCount;
|
||||
|
||||
private:
|
||||
static LeaderboardManager* m_instance;
|
||||
};
|
||||
|
||||
class DebugReadListener : public LeaderboardReadListener {
|
||||
public:
|
||||
bool OnStatsReadComplete(IPlatformLeaderboard::eStatsReturn ret,
|
||||
int numResults,
|
||||
IPlatformLeaderboard::ViewOut results) override;
|
||||
static DebugReadListener* m_instance;
|
||||
};
|
||||
|
|
@ -1,565 +0,0 @@
|
|||
#include "PlatformNetworkManagerStub.h"
|
||||
|
||||
#include <string.h>
|
||||
#include <wchar.h>
|
||||
|
||||
#include <compare>
|
||||
|
||||
#include "NetworkPlayerQNet.h"
|
||||
#include "app/common/Network/GameNetworkManager.h"
|
||||
#include "minecraft/network/Socket.h"
|
||||
#include "app/linux/LinuxGame.h"
|
||||
#include "minecraft/network/platform/NetworkPlayerInterface.h"
|
||||
#include "platform/C4JThread.h"
|
||||
#include "platform/NetTypes.h"
|
||||
|
||||
IPlatformNetworkStub* g_pPlatformNetworkManager;
|
||||
|
||||
void IPlatformNetworkStub::NotifyPlayerJoined(IQNetPlayer* pQNetPlayer) {
|
||||
const char* pszDescription;
|
||||
|
||||
// 4J Stu - We create a fake socket for every where that we need an INBOUND
|
||||
// queue of game data. Outbound is all handled by QNet so we don't need
|
||||
// that. Therefore each client player has one, and the host has one for each
|
||||
// client player.
|
||||
bool createFakeSocket = false;
|
||||
bool localPlayer = false;
|
||||
|
||||
NetworkPlayerQNet* networkPlayer =
|
||||
(NetworkPlayerQNet*)addNetworkPlayer(pQNetPlayer);
|
||||
|
||||
if (pQNetPlayer->IsLocal()) {
|
||||
localPlayer = true;
|
||||
if (pQNetPlayer->IsHost()) {
|
||||
pszDescription = "local host";
|
||||
// 4J Stu - No socket for the localhost as it uses a special
|
||||
// loopback queue
|
||||
|
||||
m_machineQNetPrimaryPlayers.push_back(pQNetPlayer);
|
||||
} else {
|
||||
pszDescription = "local";
|
||||
|
||||
// We need an inbound queue on all local players to receive data
|
||||
// from the host
|
||||
createFakeSocket = true;
|
||||
}
|
||||
} else {
|
||||
if (pQNetPlayer->IsHost()) {
|
||||
pszDescription = "remote host";
|
||||
} else {
|
||||
pszDescription = "remote";
|
||||
|
||||
// If we are the host, then create a fake socket for every remote
|
||||
// player
|
||||
if (m_pIQNet->IsHost()) {
|
||||
createFakeSocket = true;
|
||||
}
|
||||
}
|
||||
|
||||
if (m_pIQNet->IsHost() && !m_bHostChanged) {
|
||||
// Do we already have a primary player for this system?
|
||||
bool systemHasPrimaryPlayer = false;
|
||||
for (auto it = m_machineQNetPrimaryPlayers.begin();
|
||||
it < m_machineQNetPrimaryPlayers.end(); ++it) {
|
||||
IQNetPlayer* pQNetPrimaryPlayer = *it;
|
||||
if (pQNetPlayer->IsSameSystem(pQNetPrimaryPlayer)) {
|
||||
systemHasPrimaryPlayer = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!systemHasPrimaryPlayer)
|
||||
m_machineQNetPrimaryPlayers.push_back(pQNetPlayer);
|
||||
}
|
||||
}
|
||||
g_NetworkManager.PlayerJoining(networkPlayer);
|
||||
|
||||
if (createFakeSocket == true && !m_bHostChanged) {
|
||||
g_NetworkManager.CreateSocket(networkPlayer, localPlayer);
|
||||
}
|
||||
|
||||
app.DebugPrintf("Player 0x%p \"%s\" joined; %s; voice %i; camera %i.\n",
|
||||
pQNetPlayer, pQNetPlayer->GetGamertag(), pszDescription,
|
||||
(int)pQNetPlayer->HasVoice(),
|
||||
(int)pQNetPlayer->HasCamera());
|
||||
|
||||
if (m_pIQNet->IsHost()) {
|
||||
// 4J-PB - only the host should do this
|
||||
// g_NetworkManager.UpdateAndSetGameSessionData();
|
||||
SystemFlagAddPlayer(networkPlayer);
|
||||
}
|
||||
|
||||
for (int idx = 0; idx < XUSER_MAX_COUNT; ++idx) {
|
||||
if (playerChangedCallback[idx])
|
||||
playerChangedCallback[idx](networkPlayer, false);
|
||||
}
|
||||
|
||||
if (m_pIQNet->GetState() == QNET_STATE_GAME_PLAY) {
|
||||
int localPlayerCount = 0;
|
||||
for (unsigned int idx = 0; idx < XUSER_MAX_COUNT; ++idx) {
|
||||
if (m_pIQNet->GetLocalPlayerByUserIndex(idx) != nullptr)
|
||||
++localPlayerCount;
|
||||
}
|
||||
|
||||
float appTime = app.getAppTime();
|
||||
|
||||
// Only record stats for the primary player here
|
||||
m_lastPlayerEventTimeStart = appTime;
|
||||
}
|
||||
}
|
||||
|
||||
bool IPlatformNetworkStub::Initialise(CGameNetworkManager* pGameNetworkManager,
|
||||
int flagIndexSize) {
|
||||
m_pGameNetworkManager = pGameNetworkManager;
|
||||
m_flagIndexSize = flagIndexSize;
|
||||
g_pPlatformNetworkManager = this;
|
||||
// 4jcraft added this, as it was never called
|
||||
m_pIQNet = new IQNet();
|
||||
for (int i = 0; i < XUSER_MAX_COUNT; i++) {
|
||||
playerChangedCallback[i] = nullptr;
|
||||
}
|
||||
|
||||
m_bLeavingGame = false;
|
||||
m_bLeaveGameOnTick = false;
|
||||
m_bHostChanged = false;
|
||||
|
||||
m_bSearchResultsReady = false;
|
||||
m_bSearchPending = false;
|
||||
|
||||
m_bIsOfflineGame = false;
|
||||
m_SessionsUpdatedCallback = nullptr;
|
||||
|
||||
for (unsigned int i = 0; i < XUSER_MAX_COUNT; ++i) {
|
||||
m_searchResultsCount[i] = 0;
|
||||
m_lastSearchStartTime[i] = 0;
|
||||
|
||||
// The results that will be filled in with the current search
|
||||
m_pSearchResults[i] = nullptr;
|
||||
m_pQoSResult[i] = nullptr;
|
||||
m_pCurrentSearchResults[i] = nullptr;
|
||||
m_pCurrentQoSResult[i] = nullptr;
|
||||
m_currentSearchResultsCount[i] = 0;
|
||||
}
|
||||
|
||||
// Success!
|
||||
return true;
|
||||
}
|
||||
|
||||
void IPlatformNetworkStub::Terminate() {
|
||||
// TODO: 4jcraft, no release of ressources
|
||||
}
|
||||
|
||||
int IPlatformNetworkStub::GetJoiningReadyPercentage() { return 100; }
|
||||
|
||||
int IPlatformNetworkStub::CorrectErrorIDS(int IDS) { return IDS; }
|
||||
|
||||
bool IPlatformNetworkStub::isSystemPrimaryPlayer(IQNetPlayer* pQNetPlayer) {
|
||||
return true;
|
||||
}
|
||||
|
||||
// We call this twice a frame, either side of the render call so is a good place
|
||||
// to "tick" things
|
||||
void IPlatformNetworkStub::DoWork() {}
|
||||
|
||||
int IPlatformNetworkStub::GetPlayerCount() {
|
||||
return m_pIQNet->GetPlayerCount();
|
||||
}
|
||||
|
||||
bool IPlatformNetworkStub::ShouldMessageForFullSession() { return false; }
|
||||
|
||||
int IPlatformNetworkStub::GetOnlinePlayerCount() { return 1; }
|
||||
|
||||
int IPlatformNetworkStub::GetLocalPlayerMask(int playerIndex) {
|
||||
return 1 << playerIndex;
|
||||
}
|
||||
|
||||
bool IPlatformNetworkStub::AddLocalPlayerByUserIndex(int userIndex) {
|
||||
NotifyPlayerJoined(m_pIQNet->GetLocalPlayerByUserIndex(userIndex));
|
||||
return (m_pIQNet->AddLocalPlayerByUserIndex(userIndex) == 0);
|
||||
}
|
||||
|
||||
bool IPlatformNetworkStub::RemoveLocalPlayerByUserIndex(int userIndex) {
|
||||
return true;
|
||||
}
|
||||
|
||||
bool IPlatformNetworkStub::IsInStatsEnabledSession() { return true; }
|
||||
|
||||
bool IPlatformNetworkStub::SessionHasSpace(unsigned int spaceRequired /*= 1*/) {
|
||||
return true;
|
||||
}
|
||||
|
||||
void IPlatformNetworkStub::SendInviteGUI(int quadrant) {}
|
||||
|
||||
bool IPlatformNetworkStub::IsAddingPlayer() { return false; }
|
||||
|
||||
bool IPlatformNetworkStub::LeaveGame(bool bMigrateHost) {
|
||||
if (m_bLeavingGame) return true;
|
||||
|
||||
m_bLeavingGame = true;
|
||||
|
||||
// If we are the host wait for the game server to end
|
||||
if (m_pIQNet->IsHost() && g_NetworkManager.ServerStoppedValid()) {
|
||||
m_pIQNet->EndGame();
|
||||
g_NetworkManager.ServerStoppedWait();
|
||||
g_NetworkManager.ServerStoppedDestroy();
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
bool IPlatformNetworkStub::_LeaveGame(bool bMigrateHost, bool bLeaveRoom) {
|
||||
return true;
|
||||
}
|
||||
|
||||
void IPlatformNetworkStub::HostGame(
|
||||
int localUsersMask, bool bOnlineGame, bool bIsPrivate,
|
||||
unsigned char publicSlots /*= MINECRAFT_NET_MAX_PLAYERS*/,
|
||||
unsigned char privateSlots /*= 0*/) {
|
||||
// #ifdef 0
|
||||
// 4J Stu - We probably did this earlier as well, but just to be sure!
|
||||
SetLocalGame(!bOnlineGame);
|
||||
SetPrivateGame(bIsPrivate);
|
||||
SystemFlagReset();
|
||||
|
||||
// Make sure that the Primary Pad is in by default
|
||||
localUsersMask |= GetLocalPlayerMask(g_NetworkManager.GetPrimaryPad());
|
||||
|
||||
m_bLeavingGame = false;
|
||||
|
||||
m_pIQNet->HostGame();
|
||||
|
||||
_HostGame(localUsersMask, publicSlots, privateSlots);
|
||||
// #endif
|
||||
}
|
||||
|
||||
void IPlatformNetworkStub::_HostGame(
|
||||
int usersMask, unsigned char publicSlots /*= MINECRAFT_NET_MAX_PLAYERS*/,
|
||||
unsigned char privateSlots /*= 0*/) {}
|
||||
|
||||
bool IPlatformNetworkStub::_StartGame() { return true; }
|
||||
|
||||
int IPlatformNetworkStub::JoinGame(FriendSessionInfo* searchResult,
|
||||
int localUsersMask, int primaryUserIndex) {
|
||||
return CGameNetworkManager::JOINGAME_SUCCESS;
|
||||
}
|
||||
|
||||
bool IPlatformNetworkStub::SetLocalGame(bool isLocal) {
|
||||
m_bIsOfflineGame = isLocal;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void IPlatformNetworkStub::SetPrivateGame(bool isPrivate) {
|
||||
app.DebugPrintf("Setting as private game: %s\n", isPrivate ? "yes" : "no");
|
||||
m_bIsPrivateGame = isPrivate;
|
||||
}
|
||||
|
||||
void IPlatformNetworkStub::RegisterPlayerChangedCallback(
|
||||
int iPad,
|
||||
std::function<void(INetworkPlayer* pPlayer, bool leaving)> callback) {
|
||||
playerChangedCallback[iPad] = std::move(callback);
|
||||
}
|
||||
|
||||
void IPlatformNetworkStub::UnRegisterPlayerChangedCallback(int iPad) {
|
||||
playerChangedCallback[iPad] = nullptr;
|
||||
}
|
||||
|
||||
void IPlatformNetworkStub::HandleSignInChange() { return; }
|
||||
|
||||
bool IPlatformNetworkStub::_RunNetworkGame() { return true; }
|
||||
|
||||
void IPlatformNetworkStub::UpdateAndSetGameSessionData(
|
||||
INetworkPlayer* pNetworkPlayerLeaving /*= nullptr*/) {
|
||||
// uint32_t playerCount = m_pIQNet->GetPlayerCount();
|
||||
//
|
||||
// if( this->m_bLeavingGame )
|
||||
// return;
|
||||
//
|
||||
// if( GetHostPlayer() == nullptr )
|
||||
// return;
|
||||
//
|
||||
// for(unsigned int i = 0; i < MINECRAFT_NET_MAX_PLAYERS; ++i)
|
||||
// {
|
||||
// if( i < playerCount )
|
||||
// {
|
||||
// INetworkPlayer *pNetworkPlayer = GetPlayerByIndex(i);
|
||||
//
|
||||
// // We can call this from NotifyPlayerLeaving but at that
|
||||
// point the player is still considered in the session
|
||||
// if( pNetworkPlayer != pNetworkPlayerLeaving )
|
||||
// {
|
||||
// m_hostGameSessionData.players[i] =
|
||||
// ((NetworkPlayerXbox *)pNetworkPlayer)->GetUID();
|
||||
//
|
||||
// char *temp;
|
||||
// temp = (char *)wstring_to_string(
|
||||
// pNetworkPlayer->GetOnlineName() );
|
||||
// memcpy(m_hostGameSessionData.szPlayers[i],temp,XUSER_NAME_SIZE);
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// m_hostGameSessionData.players[i] = nullptr;
|
||||
// memset(m_hostGameSessionData.szPlayers[i],0,XUSER_NAME_SIZE);
|
||||
// }
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// m_hostGameSessionData.players[i] = nullptr;
|
||||
// memset(m_hostGameSessionData.szPlayers[i],0,XUSER_NAME_SIZE);
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// m_hostGameSessionData.hostPlayerUID = ((NetworkPlayerXbox
|
||||
// *)GetHostPlayer())->GetQNetPlayer()->GetXuid();
|
||||
// m_hostGameSessionData.m_uiGameHostSettings =
|
||||
// app.GetGameHostOption(eGameHostOption_All);
|
||||
}
|
||||
|
||||
int IPlatformNetworkStub::RemovePlayerOnSocketClosedThreadProc(void* lpParam) {
|
||||
INetworkPlayer* pNetworkPlayer = (INetworkPlayer*)lpParam;
|
||||
|
||||
Socket* socket = pNetworkPlayer->GetSocket();
|
||||
|
||||
if (socket != nullptr) {
|
||||
// printf("Waiting for socket closed event\n");
|
||||
socket->m_socketClosedEvent->waitForSignal(C4JThread::kInfiniteTimeout);
|
||||
|
||||
// printf("Socket closed event has fired\n");
|
||||
// 4J Stu - Clear our reference to this socket
|
||||
pNetworkPlayer->SetSocket(nullptr);
|
||||
delete socket;
|
||||
}
|
||||
|
||||
return g_pPlatformNetworkManager->RemoveLocalPlayer(pNetworkPlayer);
|
||||
}
|
||||
|
||||
bool IPlatformNetworkStub::RemoveLocalPlayer(INetworkPlayer* pNetworkPlayer) {
|
||||
return true;
|
||||
}
|
||||
|
||||
IPlatformNetworkStub::PlayerFlags::PlayerFlags(INetworkPlayer* pNetworkPlayer,
|
||||
unsigned int count) {
|
||||
// 4J Stu - Don't assert, just make it a multiple of 8! This count is
|
||||
// calculated from a load of separate values, and makes tweaking
|
||||
// world/render sizes a pain if we hit an assert here
|
||||
count = (count + 8 - 1) & ~(8 - 1);
|
||||
// assert( ( count % 8 ) == 0 );
|
||||
this->m_pNetworkPlayer = pNetworkPlayer;
|
||||
this->flags = new unsigned char[count / 8];
|
||||
memset(this->flags, 0, count / 8);
|
||||
this->count = count;
|
||||
}
|
||||
IPlatformNetworkStub::PlayerFlags::~PlayerFlags() { delete[] flags; }
|
||||
|
||||
// Add a player to the per system flag storage - if we've already got a player
|
||||
// from that system, copy its flags over
|
||||
void IPlatformNetworkStub::SystemFlagAddPlayer(INetworkPlayer* pNetworkPlayer) {
|
||||
PlayerFlags* newPlayerFlags =
|
||||
new PlayerFlags(pNetworkPlayer, m_flagIndexSize);
|
||||
// If any of our existing players are on the same system, then copy over
|
||||
// flags from that one
|
||||
for (unsigned int i = 0; i < m_playerFlags.size(); i++) {
|
||||
if (pNetworkPlayer->IsSameSystem(m_playerFlags[i]->m_pNetworkPlayer)) {
|
||||
memcpy(newPlayerFlags->flags, m_playerFlags[i]->flags,
|
||||
m_playerFlags[i]->count / 8);
|
||||
break;
|
||||
}
|
||||
}
|
||||
m_playerFlags.push_back(newPlayerFlags);
|
||||
}
|
||||
|
||||
// Remove a player from the per system flag storage - just maintains the
|
||||
// m_playerFlags vector without any gaps in it
|
||||
void IPlatformNetworkStub::SystemFlagRemovePlayer(
|
||||
INetworkPlayer* pNetworkPlayer) {
|
||||
for (unsigned int i = 0; i < m_playerFlags.size(); i++) {
|
||||
if (m_playerFlags[i]->m_pNetworkPlayer == pNetworkPlayer) {
|
||||
delete m_playerFlags[i];
|
||||
m_playerFlags[i] = m_playerFlags.back();
|
||||
m_playerFlags.pop_back();
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void IPlatformNetworkStub::SystemFlagReset() {
|
||||
for (unsigned int i = 0; i < m_playerFlags.size(); i++) {
|
||||
delete m_playerFlags[i];
|
||||
}
|
||||
m_playerFlags.clear();
|
||||
}
|
||||
|
||||
// Set a per system flag - this is done by setting the flag on every player that
|
||||
// shares that system
|
||||
void IPlatformNetworkStub::SystemFlagSet(INetworkPlayer* pNetworkPlayer,
|
||||
int index) {
|
||||
if ((index < 0) || (index >= m_flagIndexSize)) return;
|
||||
if (pNetworkPlayer == nullptr) return;
|
||||
|
||||
for (unsigned int i = 0; i < m_playerFlags.size(); i++) {
|
||||
if (pNetworkPlayer->IsSameSystem(m_playerFlags[i]->m_pNetworkPlayer)) {
|
||||
m_playerFlags[i]->flags[index / 8] |= (128 >> (index % 8));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Get value of a per system flag - can be read from the flags of the passed in
|
||||
// player as anything else sent to that system should also have been duplicated
|
||||
// here
|
||||
bool IPlatformNetworkStub::SystemFlagGet(INetworkPlayer* pNetworkPlayer,
|
||||
int index) {
|
||||
if ((index < 0) || (index >= m_flagIndexSize)) return false;
|
||||
if (pNetworkPlayer == nullptr) {
|
||||
return false;
|
||||
}
|
||||
|
||||
for (unsigned int i = 0; i < m_playerFlags.size(); i++) {
|
||||
if (m_playerFlags[i]->m_pNetworkPlayer == pNetworkPlayer) {
|
||||
return ((m_playerFlags[i]->flags[index / 8] &
|
||||
(128 >> (index % 8))) != 0);
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
std::string IPlatformNetworkStub::GatherStats() { return ""; }
|
||||
|
||||
std::string IPlatformNetworkStub::GatherRTTStats() {
|
||||
std::string stats("Rtt: ");
|
||||
|
||||
char stat[32];
|
||||
|
||||
for (unsigned int i = 0; i < GetPlayerCount(); ++i) {
|
||||
IQNetPlayer* pQNetPlayer =
|
||||
((NetworkPlayerQNet*)GetPlayerByIndex(i))->GetQNetPlayer();
|
||||
|
||||
if (!pQNetPlayer->IsLocal()) {
|
||||
memset(stat, 0, 32 * sizeof(char));
|
||||
snprintf(stat, 32, "%d: %d/", i, pQNetPlayer->GetCurrentRtt());
|
||||
stats.append(stat);
|
||||
}
|
||||
}
|
||||
return stats;
|
||||
}
|
||||
|
||||
void IPlatformNetworkStub::TickSearch() {}
|
||||
|
||||
void IPlatformNetworkStub::SearchForGames() {}
|
||||
|
||||
int IPlatformNetworkStub::SearchForGamesThreadProc(void* lpParameter) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
void IPlatformNetworkStub::SetSearchResultsReady(int resultCount) {
|
||||
m_bSearchResultsReady = true;
|
||||
m_searchResultsCount[m_lastSearchPad] = resultCount;
|
||||
}
|
||||
|
||||
std::vector<FriendSessionInfo*>* IPlatformNetworkStub::GetSessionList(
|
||||
int iPad, int localPlayers, bool partyOnly) {
|
||||
std::vector<FriendSessionInfo*>* filteredList =
|
||||
new std::vector<FriendSessionInfo*>();
|
||||
;
|
||||
return filteredList;
|
||||
}
|
||||
|
||||
bool IPlatformNetworkStub::GetGameSessionInfo(
|
||||
int iPad, SessionID sessionId, FriendSessionInfo* foundSessionInfo) {
|
||||
return false;
|
||||
}
|
||||
|
||||
void IPlatformNetworkStub::SetSessionsUpdatedCallback(
|
||||
std::function<void()> callback) {
|
||||
m_SessionsUpdatedCallback = std::move(callback);
|
||||
}
|
||||
|
||||
void IPlatformNetworkStub::GetFullFriendSessionInfo(
|
||||
FriendSessionInfo* foundSession,
|
||||
std::function<void(bool success)> callback) {
|
||||
callback(true);
|
||||
}
|
||||
|
||||
void IPlatformNetworkStub::ForceFriendsSessionRefresh() {
|
||||
app.DebugPrintf("Resetting friends session search data\n");
|
||||
|
||||
for (unsigned int i = 0; i < XUSER_MAX_COUNT; ++i) {
|
||||
m_searchResultsCount[i] = 0;
|
||||
m_lastSearchStartTime[i] = 0;
|
||||
delete m_pSearchResults[i];
|
||||
m_pSearchResults[i] = nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
INetworkPlayer* IPlatformNetworkStub::addNetworkPlayer(
|
||||
IQNetPlayer* pQNetPlayer) {
|
||||
NetworkPlayerQNet* pNetworkPlayer = new NetworkPlayerQNet(pQNetPlayer);
|
||||
pQNetPlayer->SetCustomDataValue((uintptr_t)pNetworkPlayer);
|
||||
currentNetworkPlayers.push_back(pNetworkPlayer);
|
||||
return pNetworkPlayer;
|
||||
}
|
||||
|
||||
void IPlatformNetworkStub::removeNetworkPlayer(IQNetPlayer* pQNetPlayer) {
|
||||
INetworkPlayer* pNetworkPlayer = getNetworkPlayer(pQNetPlayer);
|
||||
for (auto it = currentNetworkPlayers.begin();
|
||||
it != currentNetworkPlayers.end(); it++) {
|
||||
if (*it == pNetworkPlayer) {
|
||||
currentNetworkPlayers.erase(it);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
INetworkPlayer* IPlatformNetworkStub::getNetworkPlayer(
|
||||
IQNetPlayer* pQNetPlayer) {
|
||||
return pQNetPlayer ? (INetworkPlayer*)(pQNetPlayer->GetCustomDataValue())
|
||||
: nullptr;
|
||||
}
|
||||
|
||||
INetworkPlayer* IPlatformNetworkStub::GetLocalPlayerByUserIndex(int userIndex) {
|
||||
return getNetworkPlayer(m_pIQNet->GetLocalPlayerByUserIndex(userIndex));
|
||||
}
|
||||
|
||||
INetworkPlayer* IPlatformNetworkStub::GetPlayerByIndex(int playerIndex) {
|
||||
return getNetworkPlayer(m_pIQNet->GetPlayerByIndex(playerIndex));
|
||||
}
|
||||
|
||||
INetworkPlayer* IPlatformNetworkStub::GetPlayerByXuid(PlayerUID xuid) {
|
||||
return getNetworkPlayer(m_pIQNet->GetPlayerByXuid(xuid));
|
||||
}
|
||||
|
||||
INetworkPlayer* IPlatformNetworkStub::GetPlayerBySmallId(
|
||||
unsigned char smallId) {
|
||||
return getNetworkPlayer(m_pIQNet->GetPlayerBySmallId(smallId));
|
||||
}
|
||||
|
||||
INetworkPlayer* IPlatformNetworkStub::GetHostPlayer() {
|
||||
return getNetworkPlayer(m_pIQNet->GetHostPlayer());
|
||||
}
|
||||
|
||||
bool IPlatformNetworkStub::IsHost() {
|
||||
return m_pIQNet->IsHost() && !m_bHostChanged;
|
||||
}
|
||||
|
||||
bool IPlatformNetworkStub::JoinGameFromInviteInfo(
|
||||
int userIndex, int userMask, const INVITE_INFO* pInviteInfo) {
|
||||
return (m_pIQNet->JoinGameFromInviteInfo(userIndex, userMask,
|
||||
pInviteInfo) == 0);
|
||||
}
|
||||
|
||||
void IPlatformNetworkStub::SetSessionTexturePackParentId(int id) {
|
||||
m_hostGameSessionData.texturePackParentId = id;
|
||||
}
|
||||
|
||||
void IPlatformNetworkStub::SetSessionSubTexturePackId(int id) {
|
||||
m_hostGameSessionData.subTexturePackId = id;
|
||||
}
|
||||
|
||||
void IPlatformNetworkStub::Notify(int ID, uintptr_t Param) {}
|
||||
|
||||
bool IPlatformNetworkStub::IsInSession() {
|
||||
return m_pIQNet->GetState() != QNET_STATE_IDLE;
|
||||
}
|
||||
|
||||
bool IPlatformNetworkStub::IsInGameplay() {
|
||||
return m_pIQNet->GetState() == QNET_STATE_GAME_PLAY;
|
||||
}
|
||||
|
||||
bool IPlatformNetworkStub::IsReadyToPlayOrIdle() { return true; }
|
||||
|
|
@ -1,198 +0,0 @@
|
|||
#pragma once
|
||||
#include <stdint.h>
|
||||
// using namespace std;
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
#include "platform/network/IPlatformNetwork.h"
|
||||
#include "minecraft/client/model/SkinBox.h"
|
||||
#include "minecraft/network/platform/NetworkPlayerInterface.h"
|
||||
#include "minecraft/network/platform/SessionInfo.h"
|
||||
#include "platform/C4JThread.h"
|
||||
#include "platform/NetTypes.h"
|
||||
#include "platform/PlatformTypes.h"
|
||||
#include "platform/XboxStubs.h"
|
||||
|
||||
class C4JThread;
|
||||
class CGameNetworkManager;
|
||||
class INetworkPlayer;
|
||||
|
||||
class IPlatformNetworkStub : public IPlatformNetwork {
|
||||
friend class CGameNetworkManager;
|
||||
|
||||
public:
|
||||
virtual bool Initialise(CGameNetworkManager* pGameNetworkManager,
|
||||
int flagIndexSize);
|
||||
virtual void Terminate();
|
||||
virtual int GetJoiningReadyPercentage();
|
||||
virtual int CorrectErrorIDS(int IDS);
|
||||
|
||||
virtual void DoWork();
|
||||
virtual int GetPlayerCount();
|
||||
virtual int GetOnlinePlayerCount();
|
||||
virtual int GetLocalPlayerMask(int playerIndex);
|
||||
virtual bool AddLocalPlayerByUserIndex(int userIndex);
|
||||
virtual bool RemoveLocalPlayerByUserIndex(int userIndex);
|
||||
virtual INetworkPlayer* GetLocalPlayerByUserIndex(int userIndex);
|
||||
virtual INetworkPlayer* GetPlayerByIndex(int playerIndex);
|
||||
virtual INetworkPlayer* GetPlayerByXuid(PlayerUID xuid);
|
||||
virtual INetworkPlayer* GetPlayerBySmallId(unsigned char smallId);
|
||||
virtual bool ShouldMessageForFullSession();
|
||||
|
||||
virtual INetworkPlayer* GetHostPlayer();
|
||||
virtual bool IsHost();
|
||||
virtual bool JoinGameFromInviteInfo(int userIndex, int userMask,
|
||||
const INVITE_INFO* pInviteInfo);
|
||||
virtual bool LeaveGame(bool bMigrateHost);
|
||||
|
||||
virtual bool IsInSession();
|
||||
virtual bool IsInGameplay();
|
||||
virtual bool IsReadyToPlayOrIdle();
|
||||
virtual bool IsInStatsEnabledSession();
|
||||
virtual bool SessionHasSpace(unsigned int spaceRequired = 1);
|
||||
virtual void SendInviteGUI(int quadrant);
|
||||
virtual bool IsAddingPlayer();
|
||||
|
||||
virtual void HostGame(int localUsersMask, bool bOnlineGame, bool bIsPrivate,
|
||||
unsigned char publicSlots = MINECRAFT_NET_MAX_PLAYERS,
|
||||
unsigned char privateSlots = 0);
|
||||
virtual int JoinGame(FriendSessionInfo* searchResult, int localUsersMask,
|
||||
int primaryUserIndex);
|
||||
virtual bool SetLocalGame(bool isLocal);
|
||||
virtual bool IsLocalGame() { return m_bIsOfflineGame; }
|
||||
virtual void SetPrivateGame(bool isPrivate);
|
||||
virtual bool IsPrivateGame() { return m_bIsPrivateGame; }
|
||||
virtual bool IsLeavingGame() { return m_bLeavingGame; }
|
||||
virtual void ResetLeavingGame() { m_bLeavingGame = false; }
|
||||
|
||||
virtual void RegisterPlayerChangedCallback(
|
||||
int iPad,
|
||||
std::function<void(INetworkPlayer* pPlayer, bool leaving)> callback);
|
||||
virtual void UnRegisterPlayerChangedCallback(int iPad);
|
||||
|
||||
virtual void HandleSignInChange();
|
||||
|
||||
virtual bool _RunNetworkGame();
|
||||
|
||||
private:
|
||||
bool isSystemPrimaryPlayer(IQNetPlayer* pQNetPlayer);
|
||||
virtual bool _LeaveGame(bool bMigrateHost, bool bLeaveRoom);
|
||||
virtual void _HostGame(
|
||||
int dwUsersMask, unsigned char publicSlots = MINECRAFT_NET_MAX_PLAYERS,
|
||||
unsigned char privateSlots = 0);
|
||||
virtual bool _StartGame();
|
||||
|
||||
IQNet* m_pIQNet; // pointer to QNet interface
|
||||
|
||||
void* 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 = nullptr);
|
||||
|
||||
private:
|
||||
std::function<void(INetworkPlayer* pPlayer, bool leaving)>
|
||||
playerChangedCallback[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::string GatherStats();
|
||||
std::string 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;
|
||||
std::function<void()> m_SessionsUpdatedCallback;
|
||||
|
||||
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, uintptr_t 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(std::function<void()> callback);
|
||||
virtual void GetFullFriendSessionInfo(
|
||||
FriendSessionInfo* foundSession,
|
||||
std::function<void(bool success)> callback);
|
||||
virtual void ForceFriendsSessionRefresh();
|
||||
|
||||
private:
|
||||
void NotifyPlayerJoined(IQNetPlayer* pQNetPlayer);
|
||||
|
||||
void FakeLocalPlayerJoined() {
|
||||
NotifyPlayerJoined(m_pIQNet->GetLocalPlayerByUserIndex(0));
|
||||
}
|
||||
};
|
||||
|
|
@ -8,8 +8,7 @@
|
|||
|
||||
#include <memory>
|
||||
|
||||
#include "app/common/Leaderboards/LeaderboardInterface.h"
|
||||
#include "app/common/Leaderboards/LeaderboardManager.h"
|
||||
#include "platform/leaderboard/leaderboard.h"
|
||||
#include "app/common/UI/Controls/UIControl_Label.h"
|
||||
#include "app/common/UI/Controls/UIControl_LeaderboardList.h"
|
||||
#include "app/common/UI/UILayer.h"
|
||||
|
|
@ -96,7 +95,7 @@ const UIScene_LeaderboardsMenu::LeaderboardDescriptor UIScene_LeaderboardsMenu::
|
|||
|
||||
UIScene_LeaderboardsMenu::UIScene_LeaderboardsMenu(int iPad, void* initData,
|
||||
UILayer* parentLayer)
|
||||
: UIScene(iPad, parentLayer), m_interface(LeaderboardManager::Instance()) {
|
||||
: UIScene(iPad, parentLayer) {
|
||||
// Setup all the Iggy references we need for this scene
|
||||
initialiseMovie();
|
||||
|
||||
|
|
@ -159,7 +158,7 @@ std::string UIScene_LeaderboardsMenu::getMoviePath() {
|
|||
|
||||
void UIScene_LeaderboardsMenu::tick() {
|
||||
UIScene::tick();
|
||||
m_interface.tick();
|
||||
PlatformLeaderboard.Tick();
|
||||
}
|
||||
|
||||
void UIScene_LeaderboardsMenu::handleReload() {
|
||||
|
|
@ -208,7 +207,7 @@ void UIScene_LeaderboardsMenu::handleInput(int iPad, int key, bool repeat,
|
|||
// Do nothing if a stats read is currently in progress, otherwise
|
||||
// the system complains about to many read requests
|
||||
if (pressed && m_bPopulatedOnce &&
|
||||
LeaderboardManager::Instance()->isIdle()) {
|
||||
PlatformLeaderboard.isIdle()) {
|
||||
// CD - Added for audio
|
||||
ui.PlayUISFX(eSFX_Scroll);
|
||||
|
||||
|
|
@ -241,7 +240,7 @@ void UIScene_LeaderboardsMenu::handleInput(int iPad, int key, bool repeat,
|
|||
// Do nothing if a stats read is currently in progress, otherwise
|
||||
// the system complains about to many read requests
|
||||
if (pressed && m_bPopulatedOnce &&
|
||||
LeaderboardManager::Instance()->isIdle()) {
|
||||
PlatformLeaderboard.isIdle()) {
|
||||
// CD - Added for audio
|
||||
ui.PlayUISFX(eSFX_Scroll);
|
||||
|
||||
|
|
@ -272,7 +271,7 @@ void UIScene_LeaderboardsMenu::handleInput(int iPad, int key, bool repeat,
|
|||
// Do nothing if a stats read is currently in progress, otherwise
|
||||
// the system complains about to many read requests
|
||||
if (pressed && m_bPopulatedOnce &&
|
||||
LeaderboardManager::Instance()->isIdle()) {
|
||||
PlatformLeaderboard.isIdle()) {
|
||||
// CD - Added for audio
|
||||
ui.PlayUISFX(eSFX_Scroll);
|
||||
|
||||
|
|
@ -286,7 +285,7 @@ void UIScene_LeaderboardsMenu::handleInput(int iPad, int key, bool repeat,
|
|||
// Do nothing if a stats read is currently in progress, otherwise
|
||||
// the system complains about to many read requests
|
||||
if (pressed && m_bPopulatedOnce &&
|
||||
LeaderboardManager::Instance()->isIdle()) {
|
||||
PlatformLeaderboard.isIdle()) {
|
||||
// CD - Added for audio
|
||||
ui.PlayUISFX(eSFX_Scroll);
|
||||
|
||||
|
|
@ -348,7 +347,7 @@ void UIScene_LeaderboardsMenu::ReadStats(int startIndex) {
|
|||
m_newEntryIndex = (unsigned int)startIndex;
|
||||
// m_newReadSize = std::min((int)READ_SIZE,
|
||||
// (int)m_leaderboard.m_totalEntryCount-(startIndex-1));
|
||||
}
|
||||
}
|
||||
|
||||
// app.DebugPrintf("Requesting stats read %d - %d - %d\n",
|
||||
// m_currentLeaderboard, startIndex == -1 ? m_currentFilter :
|
||||
|
|
@ -366,7 +365,7 @@ void UIScene_LeaderboardsMenu::ReadStats(int startIndex) {
|
|||
|
||||
switch (filtermode) {
|
||||
case IPlatformLeaderboard::eFM_TopRank: {
|
||||
m_interface.ReadStats_TopRank(
|
||||
PlatformLeaderboard.ReadStats_TopRank(
|
||||
this, m_currentDifficulty,
|
||||
(IPlatformLeaderboard::EStatsType)m_currentLeaderboard,
|
||||
m_newEntryIndex, m_newReadSize);
|
||||
|
|
@ -375,7 +374,7 @@ void UIScene_LeaderboardsMenu::ReadStats(int startIndex) {
|
|||
PlayerUID uid;
|
||||
PlatformProfile.GetXUID(PlatformProfile.GetPrimaryPad(), &uid,
|
||||
true);
|
||||
m_interface.ReadStats_MyScore(
|
||||
PlatformLeaderboard.ReadStats_MyScore(
|
||||
this, m_currentDifficulty,
|
||||
(IPlatformLeaderboard::EStatsType)m_currentLeaderboard,
|
||||
uid /*ignored on PS3*/, m_newReadSize);
|
||||
|
|
@ -384,7 +383,7 @@ void UIScene_LeaderboardsMenu::ReadStats(int startIndex) {
|
|||
PlayerUID uid;
|
||||
PlatformProfile.GetXUID(PlatformProfile.GetPrimaryPad(), &uid,
|
||||
true);
|
||||
m_interface.ReadStats_Friends(
|
||||
PlatformLeaderboard.ReadStats_Friends(
|
||||
this, m_currentDifficulty,
|
||||
(IPlatformLeaderboard::EStatsType)m_currentLeaderboard,
|
||||
uid /*ignored on PS3*/, m_newEntryIndex, m_newReadSize);
|
||||
|
|
@ -406,7 +405,7 @@ bool UIScene_LeaderboardsMenu::OnStatsReadComplete(
|
|||
|
||||
m_isProcessingStatsRead = true;
|
||||
|
||||
// bool noResults = LeaderboardManager::Instance()->GetStatsState() !=
|
||||
// bool noResults = PlatformLeaderboard.GetStatsState() !=
|
||||
// XboxIPlatformLeaderboard::eStatsState_Ready;
|
||||
bool ret;
|
||||
|
||||
|
|
@ -416,7 +415,7 @@ bool UIScene_LeaderboardsMenu::OnStatsReadComplete(
|
|||
m_stats = results;
|
||||
ret = RetrieveStats();
|
||||
|
||||
// else LeaderboardManager::Instance()->SetStatsRetrieved(false);
|
||||
// else PlatformLeaderboard.SetStatsRetrieved(false);
|
||||
|
||||
PopulateLeaderboard(retIn);
|
||||
|
||||
|
|
@ -484,7 +483,7 @@ bool UIScene_LeaderboardsMenu::RetrieveStats() {
|
|||
m_leaderboard.m_entries[entryIndex].m_bRequestedFriend = false;
|
||||
}
|
||||
|
||||
// LeaderboardManager::Instance()->SetStatsRetrieved(true);
|
||||
// PlatformLeaderboard.SetStatsRetrieved(true);
|
||||
|
||||
m_newEntryIndex = 0;
|
||||
m_newEntriesCount = NUM_ENTRIES;
|
||||
|
|
@ -492,11 +491,11 @@ bool UIScene_LeaderboardsMenu::RetrieveStats() {
|
|||
return true;
|
||||
}
|
||||
|
||||
// assert( LeaderboardManager::Instance()->GetStats() != nullptr );
|
||||
// assert( PlatformLeaderboard.GetStats() != nullptr );
|
||||
// PXUSER_STATS_READ_RESULTS stats =
|
||||
// LeaderboardManager::Instance()->GetStats(); if( m_currentFilter ==
|
||||
// PlatformLeaderboard.GetStats(); if( m_currentFilter ==
|
||||
// IPlatformLeaderboard::eFM_Friends )
|
||||
// LeaderboardManager::Instance()->SortFriendStats();
|
||||
// PlatformLeaderboard.SortFriendStats();
|
||||
|
||||
bool isDistanceLeaderboard =
|
||||
LEADERBOARD_DESCRIPTORS[m_currentLeaderboard][m_currentDifficulty]
|
||||
|
|
@ -514,7 +513,7 @@ bool UIScene_LeaderboardsMenu::RetrieveStats() {
|
|||
: m_numStats;
|
||||
|
||||
if (m_leaderboard.m_totalEntryCount == 0 || m_newEntriesCount == 0) {
|
||||
// LeaderboardManager::Instance()->SetStatsRetrieved(false);
|
||||
// PlatformLeaderboard.SetStatsRetrieved(false);
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
@ -826,7 +825,7 @@ void UIScene_LeaderboardsMenu::handleRequestMoreData(F64 startIndex, bool up) {
|
|||
|
||||
if (m_leaderboard.m_totalEntryCount > 0 &&
|
||||
(item + 1) < GetEntryStartIndex()) {
|
||||
if (LeaderboardManager::Instance()->isIdle()) {
|
||||
if (PlatformLeaderboard.isIdle()) {
|
||||
int readIndex = (GetEntryStartIndex() + 1) - READ_SIZE;
|
||||
if (readIndex <= 0) readIndex = 1;
|
||||
assert(readIndex >= 1 &&
|
||||
|
|
@ -836,7 +835,7 @@ void UIScene_LeaderboardsMenu::handleRequestMoreData(F64 startIndex, bool up) {
|
|||
} else if (m_leaderboard.m_totalEntryCount > 0 &&
|
||||
(item + 1) >=
|
||||
(GetEntryStartIndex() + m_leaderboard.m_entries.size())) {
|
||||
if (LeaderboardManager::Instance()->isIdle()) {
|
||||
if (PlatformLeaderboard.isIdle()) {
|
||||
int readIndex =
|
||||
(GetEntryStartIndex() + 1) + m_leaderboard.m_entries.size();
|
||||
assert(readIndex >= 1 &&
|
||||
|
|
|
|||
|
|
@ -3,8 +3,6 @@
|
|||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
#include "app/common/Leaderboards/LeaderboardInterface.h"
|
||||
#include "app/common/Leaderboards/LeaderboardManager.h"
|
||||
#include "app/common/UI/All Platforms/UIEnums.h"
|
||||
#include "app/common/UI/Controls/UIControl_Label.h"
|
||||
#include "app/common/UI/Controls/UIControl_LeaderboardList.h"
|
||||
|
|
@ -12,6 +10,8 @@
|
|||
#include "app/linux/Iggy/include/iggy.h"
|
||||
#include "platform/PlatformTypes.h"
|
||||
#include "platform/storage/storage.h"
|
||||
#include "platform/leaderboard/leaderboard.h"
|
||||
|
||||
#ifndef _ENABLEIGGY
|
||||
#include "app/linux/Stubs/iggy_stubs.h"
|
||||
#endif
|
||||
|
|
@ -98,8 +98,6 @@ private:
|
|||
bool m_bPopulatedOnce;
|
||||
bool m_bReady;
|
||||
|
||||
LeaderboardInterface m_interface;
|
||||
|
||||
UIControl_LeaderboardList m_listEntries;
|
||||
UIControl_Label m_labelFilter, m_labelLeaderboard, m_labelEntries,
|
||||
m_labelInfo;
|
||||
|
|
|
|||
|
|
@ -45,8 +45,6 @@ common/GameRules/LevelRules/RuleDefinitions/UseTileRuleDefinition.cpp
|
|||
common/GameRules/LevelRules/Rules/GameRule.cpp
|
||||
common/GameSettingsManager.cpp
|
||||
common/Game_XuiActions.cpp
|
||||
common/Leaderboards/LeaderboardInterface.cpp
|
||||
common/Leaderboards/LeaderboardManager.cpp
|
||||
common/LocalizationManager.cpp
|
||||
common/MenuController.cpp
|
||||
common/Network/GameNetworkManager.cpp
|
||||
|
|
|
|||
|
|
@ -1,7 +0,0 @@
|
|||
#include "LinuxLeaderboardManager.h"
|
||||
|
||||
#include "app/common/Leaderboards/LeaderboardManager.h"
|
||||
|
||||
LeaderboardManager* LeaderboardManager::m_instance =
|
||||
new LinuxLeaderboardManager(); // Singleton instance of the
|
||||
// LeaderboardManager
|
||||
|
|
@ -1,52 +0,0 @@
|
|||
#pragma once
|
||||
|
||||
#include "app/common/Leaderboards/LeaderboardManager.h"
|
||||
#include "platform/PlatformTypes.h"
|
||||
|
||||
class LinuxLeaderboardManager : public LeaderboardManager {
|
||||
public:
|
||||
virtual void Tick() {}
|
||||
|
||||
// Open a session
|
||||
virtual bool OpenSession() { return true; }
|
||||
|
||||
// Close a session
|
||||
virtual void CloseSession() {}
|
||||
|
||||
// Delete a session
|
||||
virtual void DeleteSession() {}
|
||||
|
||||
// Write the given stats
|
||||
// This is called synchronously and will not free any memory allocated for
|
||||
// views when it is done
|
||||
|
||||
virtual bool WriteStats(unsigned int viewCount, ViewIn views) {
|
||||
return false;
|
||||
}
|
||||
|
||||
virtual bool ReadStats_Friends(LeaderboardReadListener* callback,
|
||||
int difficulty, EStatsType type,
|
||||
PlayerUID myUID) {
|
||||
return false;
|
||||
}
|
||||
virtual bool ReadStats_MyScore(LeaderboardReadListener* callback,
|
||||
int difficulty, EStatsType type,
|
||||
PlayerUID myUID, unsigned int readCount) {
|
||||
return false;
|
||||
}
|
||||
virtual bool ReadStats_TopRank(LeaderboardReadListener* callback,
|
||||
int difficulty, EStatsType type,
|
||||
unsigned int startIndex,
|
||||
unsigned int readCount) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// Perform a flush of the stats
|
||||
virtual void FlushStats() {}
|
||||
|
||||
// Cancel the current operation
|
||||
virtual void CancelOperation() {}
|
||||
|
||||
// Is the leaderboard manager idle.
|
||||
virtual bool isIdle() { return true; }
|
||||
};
|
||||
|
|
@ -48,7 +48,7 @@ static void sigsegv_handler(int sig) {
|
|||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
#include "app/common/Leaderboards/LeaderboardManager.h"
|
||||
#include "platform/leaderboard/leaderboard.h"
|
||||
#include "minecraft/stats/StatsCounter.h"
|
||||
#include "minecraft/world/level/Level.h"
|
||||
// #include "../Common/XUI/XUI_Scene_Container.h"
|
||||
|
|
@ -71,11 +71,6 @@ static void sigsegv_handler(int sig) {
|
|||
#include "minecraft/world/level/tile/Tile.h"
|
||||
#include "strings.h"
|
||||
|
||||
// #include "../Orbis/Leaderboards/OrbisLeaderboardManager.h"
|
||||
|
||||
// #include "../Orbis/Network/Orbis_NPToolkit.h"
|
||||
// #include "../Orbis/Network/SonyVoiceChat_Orbis.h"
|
||||
|
||||
#define THEME_NAME "584111F70AAAAAAA"
|
||||
#define THEME_FILESIZE 2797568
|
||||
|
||||
|
|
@ -518,7 +513,7 @@ int main(int argc, const char* argv[]) {
|
|||
// scenes) and pass it down via constructor injection. Once the UI
|
||||
// side is also injected, the singleton can be deleted entirely and
|
||||
// the backend constructed via std::make_unique here.
|
||||
Minecraft::main(*LeaderboardManager::Instance());
|
||||
Minecraft::main(PlatformLeaderboard);
|
||||
Minecraft* pMinecraft = Minecraft::GetInstance();
|
||||
|
||||
app.InitGameSettings();
|
||||
|
|
|
|||
|
|
@ -1,5 +1,4 @@
|
|||
linux/Iggy/gdraw/gdraw.c
|
||||
linux/Leaderboards/LinuxLeaderboardManager.cpp
|
||||
linux/LinuxGame.cpp
|
||||
linux/Linux_Minecraft.cpp
|
||||
linux/Linux_UIController.cpp
|
||||
|
|
|
|||
|
|
@ -1,5 +0,0 @@
|
|||
#include "WindowsLeaderboardManager.h"
|
||||
|
||||
LeaderboardManager* LeaderboardManager::m_instance =
|
||||
new WindowsLeaderboardManager(); // Singleton instance of the
|
||||
// LeaderboardManager
|
||||
|
|
@ -1,51 +0,0 @@
|
|||
#pragma once
|
||||
|
||||
#include "app/common/Leaderboards/LeaderboardManager.h"
|
||||
|
||||
class WindowsLeaderboardManager : public LeaderboardManager {
|
||||
public:
|
||||
virtual void Tick() {}
|
||||
|
||||
// Open a session
|
||||
virtual bool OpenSession() { return true; }
|
||||
|
||||
// Close a session
|
||||
virtual void CloseSession() {}
|
||||
|
||||
// Delete a session
|
||||
virtual void DeleteSession() {}
|
||||
|
||||
// Write the given stats
|
||||
// This is called synchronously and will not free any memory allocated for
|
||||
// views when it is done
|
||||
|
||||
virtual bool WriteStats(unsigned int viewCount, ViewIn views) {
|
||||
return false;
|
||||
}
|
||||
|
||||
virtual bool ReadStats_Friends(LeaderboardReadListener* callback,
|
||||
int difficulty, EStatsType type,
|
||||
PlayerUID myUID) {
|
||||
return false;
|
||||
}
|
||||
virtual bool ReadStats_MyScore(LeaderboardReadListener* callback,
|
||||
int difficulty, EStatsType type,
|
||||
PlayerUID myUID, unsigned int readCount) {
|
||||
return false;
|
||||
}
|
||||
virtual bool ReadStats_TopRank(LeaderboardReadListener* callback,
|
||||
int difficulty, EStatsType type,
|
||||
unsigned int startIndex,
|
||||
unsigned int readCount) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// Perform a flush of the stats
|
||||
virtual void FlushStats() {}
|
||||
|
||||
// Cancel the current operation
|
||||
virtual void CancelOperation() {}
|
||||
|
||||
// Is the leaderboard manager idle.
|
||||
virtual bool isIdle() { return true; }
|
||||
};
|
||||
|
|
@ -804,7 +804,7 @@ int APIENTRY _tWinMain(_In_ HINSTANCE hInstance,
|
|||
|
||||
// g_NetworkManager.DoWork();
|
||||
|
||||
// LeaderboardManager::Instance()->Tick();
|
||||
// PlatformLeaderboard.Tick();
|
||||
// Render game graphics.
|
||||
if (app.GetGameStarted()) {
|
||||
pMinecraft->run_middle();
|
||||
|
|
|
|||
|
|
@ -12,6 +12,7 @@
|
|||
#include "platform/C4JThread.h"
|
||||
#include "platform/PlatformTypes.h"
|
||||
#include "platform/stubs.h"
|
||||
#include "platform/leaderboard/leaderboard.h"
|
||||
|
||||
class Timer;
|
||||
class MultiPlayerLevel;
|
||||
|
|
@ -32,7 +33,6 @@ class HumanoidModel;
|
|||
class HitResult;
|
||||
class Options;
|
||||
class ConsoleSoundEngine;
|
||||
class IPlatformLeaderboard;
|
||||
class MinecraftApplet;
|
||||
class MouseHandler;
|
||||
class TexturePackRepository;
|
||||
|
|
|
|||
Loading…
Reference in a new issue