mirror of
https://github.com/DarkflameUniverse/DarkflameServer.git
synced 2026-10-02 19:03:43 +00:00
The NexusDashboard-parity dashboard (dDashboardServer) and everything built on it on the experimental branch: accounts, characters, properties and moderation tools, permissions shared with in-game slash commands, economy reports, World 3D and property 3D views with client scenery, scheduled events (features, vanity changes, live events, announcements, restarts), vanity files and events, the CDClient browser, the message inspector with saved captures, chat filter tools, community challenges, live ops, the AI moderator helper, and the server-side changes they need. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
95 lines
2.4 KiB
C++
95 lines
2.4 KiB
C++
#ifndef __LEADERBOARDMANAGER__H__
|
|
#define __LEADERBOARDMANAGER__H__
|
|
|
|
#include <map>
|
|
#include <memory>
|
|
#include <string_view>
|
|
#include <vector>
|
|
|
|
#include "dCommonVars.h"
|
|
#include "LDFFormat.h"
|
|
#include "eLeaderboardType.h"
|
|
|
|
namespace RakNet {
|
|
class BitStream;
|
|
};
|
|
|
|
using GameID = uint32_t;
|
|
|
|
class Leaderboard {
|
|
public:
|
|
|
|
// Enums for leaderboards
|
|
enum InfoType : uint32_t {
|
|
Top, // Top 11 all time players
|
|
MyStanding, // Ranking of the current player
|
|
Friends // Ranking between friends
|
|
};
|
|
|
|
// CDClient Activities.leaderboardType
|
|
using Type = eLeaderboardType;
|
|
|
|
Leaderboard() = delete;
|
|
Leaderboard(const GameID gameID, const Leaderboard::InfoType infoType, const bool weekly, LWOOBJID relatedPlayer, const uint32_t numResults, const Leaderboard::Type = Leaderboard::Type::None);
|
|
|
|
~Leaderboard();
|
|
|
|
/**
|
|
* @brief Resets the leaderboard state and frees its allocated memory
|
|
*
|
|
*/
|
|
void Clear();
|
|
|
|
/**
|
|
* Serialize the Leaderboard to a BitStream
|
|
*
|
|
* Expensive! Leaderboards are very string intensive so be wary of performatnce calling this method.
|
|
*/
|
|
void Serialize(RakNet::BitStream& bitStream) const;
|
|
|
|
/**
|
|
* 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(bool weekly);
|
|
|
|
/**
|
|
* Sends the leaderboard to the client specified by targetID.
|
|
*/
|
|
void Send(const LWOOBJID targetID) const;
|
|
|
|
|
|
|
|
private:
|
|
using LeaderboardEntries = std::vector<LwoNameValue>;
|
|
|
|
LeaderboardEntries entries;
|
|
LWOOBJID relatedPlayer;
|
|
GameID gameID;
|
|
InfoType infoType;
|
|
Leaderboard::Type leaderboardType;
|
|
bool weekly;
|
|
uint32_t numResults;
|
|
public:
|
|
LwoNameValue& PushBackEntry() {
|
|
return entries.emplace_back();
|
|
}
|
|
|
|
Type GetLeaderboardType() const {
|
|
return leaderboardType;
|
|
}
|
|
};
|
|
|
|
namespace LeaderboardManager {
|
|
void SendLeaderboard(const GameID gameID, const Leaderboard::InfoType infoType, const bool weekly, const LWOOBJID playerID, const LWOOBJID targetID, const uint32_t numResults);
|
|
|
|
void SaveScore(const LWOOBJID& playerID, const GameID activityId, const float primaryScore, const float secondaryScore = 0, const float tertiaryScore = 0);
|
|
|
|
Leaderboard::Type GetLeaderboardType(const GameID gameID);
|
|
extern std::map<GameID, Leaderboard::Type> leaderboardCache;
|
|
};
|
|
|
|
#endif //!__LEADERBOARDMANAGER__H__
|