mirror of
https://github.com/DarkflameUniverse/DarkflameServer.git
synced 2024-11-25 15:07:28 +00:00
Implement page fetching
This commit is contained in:
parent
d98ad4b94f
commit
6c2312fe87
@ -240,6 +240,8 @@ std::string Leaderboard::GetOrdering(Leaderboard::Type leaderboardType) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void Leaderboard::SetupLeaderboard(uint32_t resultStart, uint32_t resultEnd) {
|
void Leaderboard::SetupLeaderboard(uint32_t resultStart, uint32_t resultEnd) {
|
||||||
|
resultStart++;
|
||||||
|
resultEnd++;
|
||||||
std::string queryBase =
|
std::string queryBase =
|
||||||
R"QUERY(
|
R"QUERY(
|
||||||
WITH leaderboardsRanked AS (
|
WITH leaderboardsRanked AS (
|
||||||
@ -296,11 +298,11 @@ void Leaderboard::SetupLeaderboard(uint32_t resultStart, uint32_t resultEnd) {
|
|||||||
// If we are getting the friends leaderboard, add the friends query, otherwise fill it in with nothing.
|
// If we are getting the friends leaderboard, add the friends query, otherwise fill it in with nothing.
|
||||||
if (this->infoType == InfoType::Friends) {
|
if (this->infoType == InfoType::Friends) {
|
||||||
snprintf(lookupBuffer, STRING_LENGTH, queryBase.c_str(),
|
snprintf(lookupBuffer, STRING_LENGTH, queryBase.c_str(),
|
||||||
orderBase.c_str(), friendsQuery, selectBase.c_str(), resultStart + 1, resultEnd + 1);
|
orderBase.c_str(), friendsQuery, selectBase.c_str(), resultStart, resultEnd);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
snprintf(lookupBuffer, STRING_LENGTH, queryBase.c_str(),
|
snprintf(lookupBuffer, STRING_LENGTH, queryBase.c_str(),
|
||||||
orderBase.c_str(), "", selectBase.c_str(), resultStart + 1, resultEnd + 1);
|
orderBase.c_str(), "", selectBase.c_str(), resultStart, resultEnd);
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string baseLookupStr;
|
std::string baseLookupStr;
|
||||||
@ -527,10 +529,10 @@ void LeaderboardManager::SaveScore(const LWOOBJID& playerID, GameID gameID, Lead
|
|||||||
va_end(argsCopy);
|
va_end(argsCopy);
|
||||||
}
|
}
|
||||||
|
|
||||||
void LeaderboardManager::SendLeaderboard(uint32_t gameID, Leaderboard::InfoType infoType, bool weekly, LWOOBJID targetID, LWOOBJID playerID) {
|
void LeaderboardManager::SendLeaderboard(uint32_t gameID, Leaderboard::InfoType infoType, bool weekly, LWOOBJID playerID, uint32_t resultStart, uint32_t resultEnd) {
|
||||||
Leaderboard leaderboard(gameID, infoType, weekly, playerID, GetLeaderboardType(gameID));
|
Leaderboard leaderboard(gameID, infoType, weekly, playerID, GetLeaderboardType(gameID));
|
||||||
leaderboard.SetupLeaderboard();
|
leaderboard.SetupLeaderboard(resultStart, resultEnd);
|
||||||
leaderboard.Send(targetID);
|
leaderboard.Send(playerID);
|
||||||
}
|
}
|
||||||
|
|
||||||
Leaderboard::Type LeaderboardManager::GetLeaderboardType(const GameID gameID) {
|
Leaderboard::Type LeaderboardManager::GetLeaderboardType(const GameID gameID) {
|
||||||
|
@ -63,6 +63,9 @@ public:
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Builds the leaderboard from the database based on the associated gameID
|
* Builds the leaderboard from the database based on the associated gameID
|
||||||
|
*
|
||||||
|
* @param resultStart The index to start the leaderboard at. Zero indexed.
|
||||||
|
* @param resultEnd The index to end the leaderboard at. Zero indexed.
|
||||||
*/
|
*/
|
||||||
void SetupLeaderboard(uint32_t resultStart = 0, uint32_t resultEnd = 10);
|
void SetupLeaderboard(uint32_t resultStart = 0, uint32_t resultEnd = 10);
|
||||||
|
|
||||||
@ -96,7 +99,7 @@ private:
|
|||||||
class LeaderboardManager : public Singleton<LeaderboardManager> {
|
class LeaderboardManager : public Singleton<LeaderboardManager> {
|
||||||
typedef std::map<GameID, Leaderboard::Type> LeaderboardCache;
|
typedef std::map<GameID, Leaderboard::Type> LeaderboardCache;
|
||||||
public:
|
public:
|
||||||
void SendLeaderboard(GameID gameID, Leaderboard::InfoType infoType, bool weekly, LWOOBJID targetID, LWOOBJID playerID = LWOOBJID_EMPTY);
|
void SendLeaderboard(GameID gameID, Leaderboard::InfoType infoType, bool weekly, LWOOBJID playerID, uint32_t resultStart = 0, uint32_t resultEnd = 10);
|
||||||
|
|
||||||
// Saves a score to the database for the Racing minigame
|
// Saves a score to the database for the Racing minigame
|
||||||
inline void SaveRacingScore(const LWOOBJID& playerID, GameID gameID, uint32_t bestLapTime, uint32_t bestTime, bool won) {
|
inline void SaveRacingScore(const LWOOBJID& playerID, GameID gameID, uint32_t bestLapTime, uint32_t bestTime, bool won) {
|
||||||
|
@ -1647,8 +1647,8 @@ void GameMessages::HandleRequestActivitySummaryLeaderboardData(RakNet::BitStream
|
|||||||
int32_t gameID = 0;
|
int32_t gameID = 0;
|
||||||
if (inStream->ReadBit()) inStream->Read(gameID);
|
if (inStream->ReadBit()) inStream->Read(gameID);
|
||||||
|
|
||||||
int32_t queryType = 1;
|
Leaderboard::InfoType queryType = Leaderboard::InfoType::MyStanding;
|
||||||
if (inStream->ReadBit()) inStream->Read(queryType);
|
if (inStream->ReadBit()) inStream->Read<Leaderboard::InfoType>(queryType);
|
||||||
|
|
||||||
int32_t resultsEnd = 10;
|
int32_t resultsEnd = 10;
|
||||||
if (inStream->ReadBit()) inStream->Read(resultsEnd);
|
if (inStream->ReadBit()) inStream->Read(resultsEnd);
|
||||||
@ -1661,9 +1661,7 @@ void GameMessages::HandleRequestActivitySummaryLeaderboardData(RakNet::BitStream
|
|||||||
|
|
||||||
bool weekly = inStream->ReadBit();
|
bool weekly = inStream->ReadBit();
|
||||||
|
|
||||||
//const auto* leaderboard = LeaderboardManager::GetLeaderboard(gameID, (InfoType)queryType, weekly, entity->GetObjectID());
|
LeaderboardManager::Instance().SendLeaderboard(gameID, queryType, weekly, target, resultsStart, resultsEnd);
|
||||||
//SendActivitySummaryLeaderboardData(entity->GetObjectID(), leaderboard, sysAddr);
|
|
||||||
//delete leaderboard;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void GameMessages::HandleActivityStateChangeRequest(RakNet::BitStream* inStream, Entity* entity) {
|
void GameMessages::HandleActivityStateChangeRequest(RakNet::BitStream* inStream, Entity* entity) {
|
||||||
|
Loading…
Reference in New Issue
Block a user