mirror of
https://git.stillkill.net/MinecraftLeak/MinecraftConsoles-141217.git
synced 2026-10-22 13:22:18 +01:00
Initial commit
This commit is contained in:
commit
2dfcaaa842
5375 files changed
+978475
No files matched your search
@@ -0,0 +1,88 @@
|
||||
#include "stdafx.h"
|
||||
#include "LeaderboardInterface.h"
|
||||
|
||||
LeaderboardInterface::LeaderboardInterface(LeaderboardManager *man)
|
||||
{
|
||||
m_manager = man;
|
||||
m_pending = false;
|
||||
|
||||
m_filter = (LeaderboardManager::EFilterMode) -1;
|
||||
m_callback = NULL;
|
||||
m_difficulty = 0;
|
||||
m_type = LeaderboardManager::eStatsType_UNDEFINED;
|
||||
m_startIndex = 0;
|
||||
m_readCount = 0;
|
||||
|
||||
m_manager->OpenSession();
|
||||
}
|
||||
|
||||
LeaderboardInterface::~LeaderboardInterface()
|
||||
{
|
||||
m_manager->CancelOperation();
|
||||
m_manager->CloseSession();
|
||||
}
|
||||
|
||||
void LeaderboardInterface::ReadStats_Friends(LeaderboardReadListener *callback, int difficulty, LeaderboardManager::EStatsType type, PlayerUID myUID, unsigned int startIndex, unsigned int readCount)
|
||||
{
|
||||
m_filter = LeaderboardManager::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, LeaderboardManager::EStatsType type, PlayerUID myUID, unsigned int readCount)
|
||||
{
|
||||
m_filter = LeaderboardManager::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, LeaderboardManager::EStatsType type, unsigned int startIndex, unsigned int readCount)
|
||||
{
|
||||
m_filter = LeaderboardManager::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 LeaderboardManager::eFM_Friends: return m_manager->ReadStats_Friends(m_callback, m_difficulty, m_type, m_myUID, m_startIndex, m_readCount);
|
||||
case LeaderboardManager::eFM_MyScore: return m_manager->ReadStats_MyScore(m_callback, m_difficulty, m_type, m_myUID, m_readCount);
|
||||
case LeaderboardManager::eFM_TopRank: return m_manager->ReadStats_TopRank(m_callback, m_difficulty, m_type, m_startIndex, m_readCount);
|
||||
default: assert(false); return true;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,35 @@
|
||||
#pragma once
|
||||
|
||||
#include "LeaderboardManager.h"
|
||||
|
||||
// 4J-JEV: Simple interface for handling ReadStat failures.
|
||||
class LeaderboardInterface
|
||||
{
|
||||
private:
|
||||
LeaderboardManager *m_manager;
|
||||
bool m_pending;
|
||||
|
||||
// Arguments.
|
||||
LeaderboardManager::EFilterMode m_filter;
|
||||
LeaderboardReadListener *m_callback;
|
||||
int m_difficulty;
|
||||
LeaderboardManager::EStatsType m_type;
|
||||
PlayerUID m_myUID;
|
||||
unsigned int m_startIndex;
|
||||
unsigned int m_readCount;
|
||||
|
||||
public:
|
||||
LeaderboardInterface(LeaderboardManager *man);
|
||||
~LeaderboardInterface();
|
||||
|
||||
void ReadStats_Friends(LeaderboardReadListener *callback, int difficulty, LeaderboardManager::EStatsType type, PlayerUID myUID, unsigned int startIndex, unsigned int readCount);
|
||||
void ReadStats_MyScore(LeaderboardReadListener *callback, int difficulty, LeaderboardManager::EStatsType type, PlayerUID myUID, unsigned int readCount);
|
||||
void ReadStats_TopRank(LeaderboardReadListener *callback, int difficulty, LeaderboardManager::EStatsType type, unsigned int startIndex, unsigned int readCount);
|
||||
|
||||
void CancelOperation();
|
||||
|
||||
void tick();
|
||||
|
||||
private:
|
||||
bool callManager();
|
||||
};
|
||||
@@ -0,0 +1,106 @@
|
||||
#include "stdafx.h"
|
||||
|
||||
#include "..\..\..\Minecraft.World\StringHelpers.h"
|
||||
|
||||
#include "LeaderboardManager.h"
|
||||
|
||||
const wstring LeaderboardManager::filterNames[eNumFilterModes] =
|
||||
{
|
||||
L"Friends", L"MyScore", L"TopRank"
|
||||
};
|
||||
|
||||
void LeaderboardManager::DeleteInstance()
|
||||
{
|
||||
delete m_instance;
|
||||
m_instance = NULL;
|
||||
}
|
||||
|
||||
LeaderboardManager::LeaderboardManager()
|
||||
{
|
||||
zeroReadParameters();
|
||||
|
||||
m_myXUID = INVALID_XUID;
|
||||
}
|
||||
|
||||
void LeaderboardManager::zeroReadParameters()
|
||||
{
|
||||
m_difficulty = -1;
|
||||
m_statsType = eStatsType_UNDEFINED;
|
||||
m_readListener = NULL;
|
||||
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;
|
||||
}
|
||||
|
||||
#ifndef _XBOX
|
||||
void LeaderboardManager::printStats(ReadView &view)
|
||||
{
|
||||
app.DebugPrintf("[LeaderboardManager] Printing stats:\n"
|
||||
"\tnumQueries=%i\n", view.m_numQueries);
|
||||
|
||||
for (int i=0; i<view.m_numQueries; i++)
|
||||
{
|
||||
ReadScore score = view.m_queries[i];
|
||||
|
||||
app.DebugPrintf( "\tname='%s'\n", wstringtofilename(wstring(score.m_name)) );
|
||||
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(LeaderboardManager::eStatsReturn success, int numResults, LeaderboardManager::ViewOut results)
|
||||
{
|
||||
app.DebugPrintf("[DebugReadListener] OnStatsReadComplete, %s:\n", (success ? "success" : "FAILED") );
|
||||
LeaderboardManager::printStats(results);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
DebugReadListener *DebugReadListener::m_instance = new DebugReadListener();
|
||||
#endif
|
||||
@@ -0,0 +1,268 @@
|
||||
#pragma once
|
||||
|
||||
// Forward Declarations.
|
||||
class LeaderboardManager;
|
||||
|
||||
// READ LISTENTER //
|
||||
class LeaderboardReadListener;
|
||||
|
||||
// ABSTRACT CLASS //
|
||||
class LeaderboardManager
|
||||
{
|
||||
public:
|
||||
enum eStatsReturn
|
||||
{
|
||||
eStatsReturn_Success=0,
|
||||
eStatsReturn_NoResults,
|
||||
eStatsReturn_NetworkError
|
||||
};
|
||||
|
||||
enum eProperty_Kills
|
||||
{
|
||||
eProperty_Kills_Zombie=0,
|
||||
eProperty_Kills_Skeleton,
|
||||
eProperty_Kills_Creeper,
|
||||
eProperty_Kills_Spider,
|
||||
eProperty_Kills_SpiderJockey,
|
||||
eProperty_Kills_ZombiePigman,
|
||||
eProperty_Kills_Slime,
|
||||
eProperty_Kills_Rating,
|
||||
eProperty_Kills_Max,
|
||||
};
|
||||
|
||||
enum eProperty_Mining
|
||||
{
|
||||
eProperty_Mining_Dirt=0,
|
||||
eProperty_Mining_Stone,
|
||||
eProperty_Mining_Sand,
|
||||
eProperty_Mining_Cobblestone,
|
||||
eProperty_Mining_Gravel,
|
||||
eProperty_Mining_Clay,
|
||||
eProperty_Mining_Obsidian,
|
||||
eProperty_Mining_Rating,
|
||||
eProperty_Mining_Max,
|
||||
};
|
||||
|
||||
enum eProperty_Farming
|
||||
{
|
||||
eProperty_Farming_Egg=0,
|
||||
eProperty_Farming_Wheat,
|
||||
eProperty_Farming_Mushroom,
|
||||
eProperty_Farming_Sugarcane,
|
||||
eProperty_Farming_Milk,
|
||||
eProperty_Farming_Pumpkin,
|
||||
eProperty_Farming_Rating,
|
||||
eProperty_Farming_Max,
|
||||
};
|
||||
|
||||
enum eProperty_Travelling
|
||||
{
|
||||
eProperty_Travelling_Walked=0,
|
||||
eProperty_Travelling_Fallen,
|
||||
eProperty_Travelling_Minecart,
|
||||
eProperty_Travelling_Boat,
|
||||
eProperty_Travelling_Rating,
|
||||
eProperty_Travelling_Max,
|
||||
};
|
||||
|
||||
enum EStatsType
|
||||
{
|
||||
eStatsType_Travelling=0,
|
||||
eStatsType_Mining,
|
||||
eStatsType_Farming,
|
||||
eStatsType_Kills,
|
||||
eStatsType_MAX,
|
||||
eStatsType_UNDEFINED
|
||||
};
|
||||
|
||||
enum EFilterMode
|
||||
{
|
||||
eFM_Friends=0, //Stats belonging to current user's friends
|
||||
eFM_MyScore, //Stats around the current user's rank
|
||||
eFM_TopRank, //Stats at the top of the leaderboard
|
||||
eNumFilterModes,
|
||||
eFM_UNDEFINED
|
||||
};
|
||||
|
||||
static const wstring filterNames[eNumFilterModes];
|
||||
|
||||
typedef struct KillsRecord
|
||||
{
|
||||
public:
|
||||
unsigned short m_zombie;
|
||||
unsigned short m_skeleton;
|
||||
unsigned short m_creeper;
|
||||
unsigned short m_spider;
|
||||
unsigned short m_spiderJockey;
|
||||
unsigned short m_zombiePigman;
|
||||
unsigned short m_slime;
|
||||
} KillsRecord;
|
||||
|
||||
typedef struct MiningRecord
|
||||
{
|
||||
public:
|
||||
unsigned short m_dirt;
|
||||
unsigned short m_stone;
|
||||
unsigned short m_sand;
|
||||
unsigned short m_cobblestone;
|
||||
unsigned short m_gravel;
|
||||
unsigned short m_clay;
|
||||
unsigned short m_obsidian;
|
||||
} MiningRecord;
|
||||
|
||||
typedef struct FarmingRecord
|
||||
{
|
||||
public:
|
||||
unsigned short m_eggs;
|
||||
unsigned short m_wheat;
|
||||
unsigned short m_mushroom;
|
||||
unsigned short m_sugarcane;
|
||||
unsigned short m_milk;
|
||||
unsigned short m_pumpkin;
|
||||
} FarmingRecord;
|
||||
|
||||
typedef struct TravellingRecord
|
||||
{
|
||||
public:
|
||||
unsigned int m_walked;
|
||||
unsigned int m_fallen;
|
||||
unsigned int m_minecart;
|
||||
unsigned int m_boat;
|
||||
} TravellingRecord;
|
||||
|
||||
|
||||
|
||||
public:
|
||||
#ifdef _XBOX
|
||||
typedef XSESSION_VIEW_PROPERTIES *ViewIn;
|
||||
typedef PXUSER_STATS_READ_RESULTS ViewOut;
|
||||
#else
|
||||
static const int RECORD_SIZE = 40; //base32
|
||||
|
||||
typedef struct StatsData
|
||||
{
|
||||
EStatsType m_statsType;
|
||||
union
|
||||
{
|
||||
LeaderboardManager::KillsRecord m_kills;
|
||||
LeaderboardManager::MiningRecord m_mining;
|
||||
LeaderboardManager::FarmingRecord m_farming;
|
||||
LeaderboardManager::TravellingRecord m_travelling;
|
||||
unsigned char m_padding[RECORD_SIZE];
|
||||
};
|
||||
} StatsData;
|
||||
|
||||
typedef struct RegisterScore
|
||||
{
|
||||
int m_iPad;
|
||||
int m_score;
|
||||
int m_difficulty;
|
||||
StatsData m_commentData;
|
||||
} RegisterScore;
|
||||
|
||||
typedef struct ReadScore
|
||||
{
|
||||
// Maximum number of columns in a scoreboard.
|
||||
static const unsigned int STATSDATA_MAX = 8;
|
||||
|
||||
PlayerUID m_uid; // Player's unique identifier.
|
||||
unsigned long m_rank; // Rank of the player on this scoreboard.
|
||||
wstring m_name; // Player's display name.
|
||||
|
||||
unsigned long m_totalScore; // Sum of all the player's scores on this leaderboard.
|
||||
|
||||
unsigned short m_statsSize; // Iff (m_hasResults): Number of columns on this leaderboard.
|
||||
unsigned long m_statsData[STATSDATA_MAX]; // Iff (m_hasResults): Player's score for each appropriate column.
|
||||
|
||||
int m_idsErrorMessage; // Iff (not m_hasResults): error message explaining what went wrong.
|
||||
|
||||
} ReadScore;
|
||||
|
||||
typedef struct ReadView
|
||||
{
|
||||
unsigned int m_numQueries;
|
||||
ReadScore *m_queries;
|
||||
|
||||
} ReadView;
|
||||
|
||||
typedef ReadView ViewOut;
|
||||
typedef RegisterScore *ViewIn;
|
||||
#endif
|
||||
|
||||
|
||||
public:
|
||||
LeaderboardManager();
|
||||
virtual ~LeaderboardManager() {}
|
||||
|
||||
protected:
|
||||
virtual void zeroReadParameters();
|
||||
|
||||
EFilterMode m_eFilterMode;
|
||||
|
||||
// Parameters for reading.
|
||||
int m_difficulty;
|
||||
EStatsType m_statsType;
|
||||
LeaderboardReadListener *m_readListener;
|
||||
PlayerUID m_myXUID;
|
||||
unsigned int m_startIndex, m_readCount;
|
||||
|
||||
private:
|
||||
static LeaderboardManager *m_instance; //Singleton instance of the LeaderboardManager
|
||||
|
||||
public:
|
||||
static LeaderboardManager *Instance() { return m_instance; }
|
||||
static void DeleteInstance();
|
||||
|
||||
virtual void Tick() = 0;
|
||||
|
||||
//Open a session
|
||||
virtual bool OpenSession() = 0;
|
||||
|
||||
//Close a session
|
||||
virtual void CloseSession() = 0;
|
||||
|
||||
//Delete a session
|
||||
virtual void DeleteSession() = 0;
|
||||
|
||||
//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) = 0;
|
||||
|
||||
virtual bool ReadStats_Friends(LeaderboardReadListener *callback, int difficulty, EStatsType type, PlayerUID myUID, unsigned int startIndex, unsigned int readCount);
|
||||
virtual bool ReadStats_MyScore(LeaderboardReadListener *callback, int difficulty, EStatsType type, PlayerUID myUID, unsigned int readCount);
|
||||
virtual bool ReadStats_TopRank(LeaderboardReadListener *callback, int difficulty, EStatsType type, unsigned int startIndex, unsigned int readCount);
|
||||
|
||||
//Perform a flush of the stats
|
||||
virtual void FlushStats() = 0;
|
||||
|
||||
//Cancel the current operation
|
||||
virtual void CancelOperation() = 0;
|
||||
|
||||
//Is the leaderboard manager idle.
|
||||
virtual bool isIdle() = 0;
|
||||
|
||||
public:
|
||||
#ifndef _XBOX
|
||||
static void printStats(ReadView &view);
|
||||
#endif
|
||||
};
|
||||
|
||||
class LeaderboardReadListener
|
||||
{
|
||||
public:
|
||||
#ifdef _XBOX
|
||||
virtual bool OnStatsReadComplete(bool success, int numResults, LeaderboardManager::ViewOut results) = 0;
|
||||
#else
|
||||
virtual bool OnStatsReadComplete(LeaderboardManager::eStatsReturn ret, int numResults, LeaderboardManager::ViewOut results) = 0;
|
||||
#endif
|
||||
};
|
||||
|
||||
#ifndef _XBOX
|
||||
class DebugReadListener : public LeaderboardReadListener
|
||||
{
|
||||
public:
|
||||
virtual bool OnStatsReadComplete(LeaderboardManager::eStatsReturn ret, int numResults, LeaderboardManager::ViewOut results);
|
||||
static DebugReadListener *m_instance;
|
||||
};
|
||||
#endif
|
||||
File diff suppressed because it is too large.
Load diff
@@ -0,0 +1,133 @@
|
||||
#pragma once
|
||||
|
||||
#include "Common\Leaderboards\LeaderboardManager.h"
|
||||
|
||||
#ifdef __PS3__
|
||||
typedef CellRtcTick SonyRtcTick;
|
||||
#else
|
||||
typedef SceRtcTick SonyRtcTick;
|
||||
#endif
|
||||
|
||||
class SonyLeaderboardManager : public LeaderboardManager
|
||||
{
|
||||
protected:
|
||||
enum EStatsState
|
||||
{
|
||||
eStatsState_Idle,
|
||||
eStatsState_Getting,
|
||||
eStatsState_Failed,
|
||||
eStatsState_Ready,
|
||||
eStatsState_Canceled,
|
||||
eStatsState_Max
|
||||
};
|
||||
|
||||
public:
|
||||
SonyLeaderboardManager();
|
||||
virtual ~SonyLeaderboardManager();
|
||||
|
||||
protected:
|
||||
unsigned short m_openSessions;
|
||||
|
||||
C4JThread *m_threadScoreboard;
|
||||
bool m_running;
|
||||
|
||||
int m_titleContext;
|
||||
int32_t m_requestId;
|
||||
|
||||
//SceNpId m_myNpId;
|
||||
|
||||
static int scoreboardThreadEntry(LPVOID lpParam);
|
||||
void scoreboardThreadInternal();
|
||||
|
||||
virtual bool getScoreByIds();
|
||||
virtual bool getScoreByRange();
|
||||
|
||||
virtual bool setScore();
|
||||
|
||||
queue<RegisterScore> m_views;
|
||||
|
||||
CRITICAL_SECTION m_csViewsLock;
|
||||
|
||||
EStatsState m_eStatsState; //State of the stats read
|
||||
// EFilterMode m_eFilterMode;
|
||||
|
||||
ReadScore *m_scores;
|
||||
unsigned int m_maxRank;
|
||||
//SceNpScoreRankData *m_stats;
|
||||
|
||||
public:
|
||||
virtual void Tick();
|
||||
|
||||
//Open a session
|
||||
virtual bool OpenSession();
|
||||
|
||||
//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);
|
||||
|
||||
virtual bool ReadStats_Friends(LeaderboardReadListener *callback, int difficulty, EStatsType type, PlayerUID myUID, unsigned int startIndex, unsigned int readCount);
|
||||
virtual bool ReadStats_MyScore(LeaderboardReadListener *callback, int difficulty, EStatsType type, PlayerUID myUID, unsigned int readCount);
|
||||
virtual bool ReadStats_TopRank(LeaderboardReadListener *callback, int difficulty, EStatsType type, unsigned int startIndex, unsigned int readCount);
|
||||
|
||||
//Perform a flush of the stats
|
||||
virtual void FlushStats();
|
||||
|
||||
//Cancel the current operation
|
||||
virtual void CancelOperation();
|
||||
|
||||
//Is the leaderboard manager idle.
|
||||
virtual bool isIdle();
|
||||
|
||||
protected:
|
||||
int getBoardId(int difficulty, EStatsType);
|
||||
|
||||
SceNpScorePlayerRankData *addPadding(unsigned int num, SceNpScoreRankData *rankData);
|
||||
|
||||
void convertToOutput(unsigned int &num, ReadScore *out, SceNpScorePlayerRankData *rankData, SceNpScoreComment *comm);
|
||||
|
||||
void toBinary(void *out, SceNpScoreComment *in);
|
||||
void fromBinary(SceNpScoreComment **out, void *in);
|
||||
|
||||
void toBase32(SceNpScoreComment *out, void *in);
|
||||
void fromBase32(void *out, SceNpScoreComment *in);
|
||||
|
||||
void toSymbols(char *);
|
||||
void fromSymbols(char *);
|
||||
|
||||
bool test_string(string);
|
||||
|
||||
void initReadScoreStruct(ReadScore &out, SceNpScoreRankData &);
|
||||
void fillReadScoreStruct(ReadScore &out, SceNpScoreComment &comment);
|
||||
|
||||
static bool SortByRank(const ReadScore &lhs, const ReadScore &rhs);
|
||||
|
||||
|
||||
protected:
|
||||
// 4J-JEV: Interface differences:
|
||||
|
||||
// Sce NP score library function redirects.
|
||||
virtual HRESULT initialiseScoreUtility() { return ERROR_SUCCESS; }
|
||||
virtual bool scoreUtilityAlreadyInitialised(HRESULT hr) { return false; }
|
||||
|
||||
virtual HRESULT createTitleContext(const SceNpId &npId) = 0;
|
||||
virtual HRESULT destroyTitleContext(int titleContext) = 0;
|
||||
|
||||
virtual HRESULT createTransactionContext(int titleContext) = 0;
|
||||
virtual HRESULT abortTransactionContext(int transactionContext) = 0;
|
||||
virtual HRESULT destroyTransactionContext(int transactionContext) = 0;
|
||||
|
||||
virtual HRESULT fillByIdsQuery(const SceNpId &myNpId, SceNpId* &npIds, uint32_t &len);
|
||||
|
||||
#if (defined __ORBIS__) || (defined __PSVITA__)
|
||||
virtual HRESULT getFriendsList(sce::Toolkit::NP::Utilities::Future<sce::Toolkit::NP::FriendsList> &friendsList) = 0;
|
||||
#endif
|
||||
|
||||
virtual char * getComment(SceNpScoreComment *comment) = 0;
|
||||
};
|
||||
@@ -0,0 +1,131 @@
|
||||
/*
|
||||
base64.cpp and base64.h
|
||||
|
||||
Copyright (C) 2004-2008 René Nyffenegger
|
||||
|
||||
This source code is provided 'as-is', without any express or implied
|
||||
warranty. In no event will the author be held liable for any damages
|
||||
arising from the use of this software.
|
||||
|
||||
Permission is granted to anyone to use this software for any purpose,
|
||||
including commercial applications, and to alter it and redistribute it
|
||||
freely, subject to the following restrictions:
|
||||
|
||||
1. The origin of this source code must not be misrepresented; you must not
|
||||
claim that you wrote the original source code. If you use this source code
|
||||
in a product, an acknowledgment in the product documentation would be
|
||||
appreciated but is not required.
|
||||
|
||||
2. Altered source versions must be plainly marked as such, and must not be
|
||||
misrepresented as being the original source code.
|
||||
|
||||
3. This notice may not be removed or altered from any source distribution.
|
||||
|
||||
René Nyffenegger rene.nyffenegger@adp-gmbh.ch
|
||||
|
||||
*/
|
||||
|
||||
#include "stdafx.h"
|
||||
|
||||
#include "base64.h"
|
||||
#include <iostream>
|
||||
|
||||
static const std::string base64_chars =
|
||||
"ABCDEFGHIJKLMNOPQRSTUVWXYZ"
|
||||
"abcdefghijklmnopqrstuvwxyz"
|
||||
"0123456789+/";
|
||||
|
||||
|
||||
static inline bool is_base64(unsigned char c) {
|
||||
return (isalnum(c) || (c == '+') || (c == '/'));
|
||||
}
|
||||
|
||||
// 4J ADDED,
|
||||
std::string base64_encode(std::string str)
|
||||
{
|
||||
return base64_encode( reinterpret_cast<const unsigned char*>(str.c_str()), str.length() );
|
||||
}
|
||||
|
||||
std::string base64_encode(unsigned char const* bytes_to_encode, unsigned int in_len) {
|
||||
std::string ret;
|
||||
int i = 0;
|
||||
int j = 0;
|
||||
unsigned char char_array_3[3];
|
||||
unsigned char char_array_4[4];
|
||||
|
||||
while (in_len--) {
|
||||
char_array_3[i++] = *(bytes_to_encode++);
|
||||
if (i == 3) {
|
||||
char_array_4[0] = (char_array_3[0] & 0xfc) >> 2;
|
||||
char_array_4[1] = ((char_array_3[0] & 0x03) << 4) + ((char_array_3[1] & 0xf0) >> 4);
|
||||
char_array_4[2] = ((char_array_3[1] & 0x0f) << 2) + ((char_array_3[2] & 0xc0) >> 6);
|
||||
char_array_4[3] = char_array_3[2] & 0x3f;
|
||||
|
||||
for(int ii = 0; (ii <4) ; ii++)
|
||||
ret += base64_chars[char_array_4[ii]];
|
||||
i = 0;
|
||||
}
|
||||
}
|
||||
|
||||
if (i)
|
||||
{
|
||||
for(j = i; j < 3; j++)
|
||||
char_array_3[j] = '\0';
|
||||
|
||||
char_array_4[0] = (char_array_3[0] & 0xfc) >> 2;
|
||||
char_array_4[1] = ((char_array_3[0] & 0x03) << 4) + ((char_array_3[1] & 0xf0) >> 4);
|
||||
char_array_4[2] = ((char_array_3[1] & 0x0f) << 2) + ((char_array_3[2] & 0xc0) >> 6);
|
||||
char_array_4[3] = char_array_3[2] & 0x3f;
|
||||
|
||||
for (j = 0; (j < i + 1); j++)
|
||||
ret += base64_chars[char_array_4[j]];
|
||||
|
||||
while((i++ < 3))
|
||||
ret += '=';
|
||||
|
||||
}
|
||||
|
||||
return ret;
|
||||
|
||||
}
|
||||
|
||||
std::string base64_decode(std::string const& encoded_string) {
|
||||
int in_len = encoded_string.size();
|
||||
int i = 0;
|
||||
int j = 0;
|
||||
int in_ = 0;
|
||||
unsigned char char_array_4[4], char_array_3[3];
|
||||
std::string ret;
|
||||
|
||||
while (in_len-- && ( encoded_string[in_] != '=') && is_base64(encoded_string[in_])) {
|
||||
char_array_4[i++] = encoded_string[in_]; in_++;
|
||||
if (i ==4) {
|
||||
for (i = 0; i <4; i++)
|
||||
char_array_4[i] = base64_chars.find(char_array_4[i]);
|
||||
|
||||
char_array_3[0] = (char_array_4[0] << 2) + ((char_array_4[1] & 0x30) >> 4);
|
||||
char_array_3[1] = ((char_array_4[1] & 0xf) << 4) + ((char_array_4[2] & 0x3c) >> 2);
|
||||
char_array_3[2] = ((char_array_4[2] & 0x3) << 6) + char_array_4[3];
|
||||
|
||||
for (i = 0; (i < 3); i++)
|
||||
ret += char_array_3[i];
|
||||
i = 0;
|
||||
}
|
||||
}
|
||||
|
||||
if (i) {
|
||||
for (j = i; j <4; j++)
|
||||
char_array_4[j] = 0;
|
||||
|
||||
for (j = 0; j <4; j++)
|
||||
char_array_4[j] = base64_chars.find(char_array_4[j]);
|
||||
|
||||
char_array_3[0] = (char_array_4[0] << 2) + ((char_array_4[1] & 0x30) >> 4);
|
||||
char_array_3[1] = ((char_array_4[1] & 0xf) << 4) + ((char_array_4[2] & 0x3c) >> 2);
|
||||
char_array_3[2] = ((char_array_4[2] & 0x3) << 6) + char_array_4[3];
|
||||
|
||||
for (j = 0; (j < i - 1); j++) ret += char_array_3[j];
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
#pragma once
|
||||
|
||||
#include <string>
|
||||
|
||||
std::string base64_encode(std::string str);
|
||||
std::string base64_encode(unsigned char const* , unsigned int len);
|
||||
std::string base64_decode(std::string const& s);
|
||||
Reference in new issue
Block a user