2018-07-06 14:11:38 +00:00
|
|
|
#ifndef GAME_SERVER_SCORE_H
|
|
|
|
#define GAME_SERVER_SCORE_H
|
2010-07-29 05:21:18 +00:00
|
|
|
|
2020-09-26 19:41:58 +00:00
|
|
|
#include <engine/server/databases/connection_pool.h>
|
2020-07-04 17:53:27 +00:00
|
|
|
#include <game/prng.h>
|
|
|
|
|
2020-05-26 21:22:16 +00:00
|
|
|
#include "save.h"
|
2021-11-24 12:09:07 +00:00
|
|
|
#include "scoreworker.h"
|
2010-08-20 17:45:09 +00:00
|
|
|
|
2020-07-04 17:53:27 +00:00
|
|
|
class CGameContext;
|
|
|
|
|
|
|
|
class CScore
|
2010-07-29 05:21:18 +00:00
|
|
|
{
|
2010-08-23 19:37:27 +00:00
|
|
|
CPlayerData m_aPlayerData[MAX_CLIENTS];
|
2020-07-04 17:53:27 +00:00
|
|
|
CDbConnectionPool *m_pPool;
|
|
|
|
|
|
|
|
CGameContext *GameServer() const { return m_pGameServer; }
|
|
|
|
IServer *Server() const { return m_pServer; }
|
|
|
|
CGameContext *m_pGameServer;
|
|
|
|
IServer *m_pServer;
|
|
|
|
|
|
|
|
std::vector<std::string> m_aWordlist;
|
|
|
|
CPrng m_Prng;
|
|
|
|
void GeneratePassphrase(char *pBuf, int BufSize);
|
|
|
|
|
|
|
|
// returns new SqlResult bound to the player, if no current Thread is active for this player
|
|
|
|
std::shared_ptr<CScorePlayerResult> NewSqlPlayerResult(int ClientID);
|
|
|
|
// Creates for player database requests
|
|
|
|
void ExecPlayerThread(
|
2021-01-31 16:58:30 +00:00
|
|
|
bool (*pFuncPtr)(IDbConnection *, const ISqlData *, char *pError, int ErrorSize),
|
2020-09-26 19:41:58 +00:00
|
|
|
const char *pThreadName,
|
|
|
|
int ClientID,
|
|
|
|
const char *pName,
|
|
|
|
int Offset);
|
2020-07-04 17:53:27 +00:00
|
|
|
|
|
|
|
// returns true if the player should be rate limited
|
|
|
|
bool RateLimitPlayer(int ClientID);
|
2014-10-10 23:01:32 +00:00
|
|
|
|
2010-07-29 05:21:18 +00:00
|
|
|
public:
|
2020-07-04 17:53:27 +00:00
|
|
|
CScore(CGameContext *pGameServer, CDbConnectionPool *pPool);
|
|
|
|
~CScore() {}
|
2014-10-10 23:01:32 +00:00
|
|
|
|
2010-08-23 19:37:27 +00:00
|
|
|
CPlayerData *PlayerData(int ID) { return &m_aPlayerData[ID]; }
|
2014-10-10 23:01:32 +00:00
|
|
|
|
2020-07-04 17:53:27 +00:00
|
|
|
void MapInfo(int ClientID, const char *pMapName);
|
|
|
|
void MapVote(int ClientID, const char *pMapName);
|
|
|
|
void LoadPlayerData(int ClientID);
|
|
|
|
void SaveScore(int ClientID, float Time, const char *pTimestamp, float aCpTime[NUM_CHECKPOINTS], bool NotEligible);
|
2014-10-10 23:01:32 +00:00
|
|
|
|
2020-07-04 17:53:27 +00:00
|
|
|
void SaveTeamScore(int *pClientIDs, unsigned int Size, float Time, const char *pTimestamp);
|
2013-07-21 02:52:23 +00:00
|
|
|
|
2021-03-07 22:39:11 +00:00
|
|
|
void ShowTop(int ClientID, int Offset = 1);
|
2020-07-04 17:53:27 +00:00
|
|
|
void ShowRank(int ClientID, const char *pName);
|
2013-07-21 06:46:52 +00:00
|
|
|
|
2020-09-26 19:41:58 +00:00
|
|
|
void ShowTeamTop5(int ClientID, int Offset = 1);
|
2022-03-28 19:51:50 +00:00
|
|
|
void ShowPlayerTeamTop5(int ClientID, const char *pName, int Offset = 1);
|
2020-07-04 17:53:27 +00:00
|
|
|
void ShowTeamRank(int ClientID, const char *pName);
|
2014-06-20 20:40:23 +00:00
|
|
|
|
2020-09-26 19:41:58 +00:00
|
|
|
void ShowTopPoints(int ClientID, int Offset = 1);
|
2020-07-04 17:53:27 +00:00
|
|
|
void ShowPoints(int ClientID, const char *pName);
|
2020-06-24 21:14:09 +00:00
|
|
|
|
2020-07-04 17:53:27 +00:00
|
|
|
void ShowTimes(int ClientID, const char *pName, int Offset = 1);
|
|
|
|
void ShowTimes(int ClientID, int Offset = 1);
|
2014-10-10 23:01:32 +00:00
|
|
|
|
2020-07-04 17:53:27 +00:00
|
|
|
void RandomMap(int ClientID, int Stars);
|
|
|
|
void RandomUnfinishedMap(int ClientID, int Stars);
|
2016-05-04 13:32:24 +00:00
|
|
|
|
2020-07-04 17:53:27 +00:00
|
|
|
void SaveTeam(int ClientID, const char *pCode, const char *pServer);
|
|
|
|
void LoadTeam(const char *pCode, int ClientID);
|
|
|
|
void GetSaves(int ClientID);
|
2010-07-29 05:21:18 +00:00
|
|
|
};
|
|
|
|
|
2018-07-06 14:11:38 +00:00
|
|
|
#endif // GAME_SERVER_SCORE_H
|