1#ifndef GAME_SERVER_SCORE_H
2#define GAME_SERVER_SCORE_H
3
4#include <game/prng.h>
5
6#include "scoreworker.h"
7
8class CDbConnectionPool;
9class CGameContext;
10class IDbConnection;
11class IServer;
12struct ISqlData;
13
14class CScore
15{
16 CPlayerData m_aPlayerData[MAX_CLIENTS];
17 CDbConnectionPool *m_pPool;
18
19 CGameContext *GameServer() const { return m_pGameServer; }
20 IServer *Server() const { return m_pServer; }
21 CGameContext *m_pGameServer;
22 IServer *m_pServer;
23
24 std::vector<std::string> m_vWordlist;
25 CPrng m_Prng;
26 void GeneratePassphrase(char *pBuf, int BufSize);
27
28 // returns new SqlResult bound to the player, if no current Thread is active for this player
29 std::shared_ptr<CScorePlayerResult> NewSqlPlayerResult(int ClientId);
30 // Creates for player database requests
31 void ExecPlayerThread(
32 bool (*pFuncPtr)(IDbConnection *, const ISqlData *, char *pError, int ErrorSize),
33 const char *pThreadName,
34 int ClientId,
35 const char *pName,
36 int Offset);
37
38 // returns true if the player should be rate limited
39 bool RateLimitPlayer(int ClientId);
40
41public:
42 CScore(CGameContext *pGameServer, CDbConnectionPool *pPool);
43 ~CScore() {}
44
45 CPlayerData *PlayerData(int Id) { return &m_aPlayerData[Id]; }
46
47 void LoadBestTime();
48 void MapInfo(int ClientId, const char *pMapName);
49 void MapVote(int ClientId, const char *pMapName);
50 void LoadPlayerData(int ClientId, const char *pName = "");
51 void LoadPlayerTimeCp(int ClientId, const char *pName = "");
52 void SaveScore(int ClientId, int TimeTicks, const char *pTimestamp, const float aTimeCp[NUM_CHECKPOINTS], bool NotEligible);
53
54 void SaveTeamScore(int Team, int *pClientIds, unsigned int Size, int TimeTicks, const char *pTimestamp);
55
56 void ShowTop(int ClientId, int Offset = 1);
57 void ShowRank(int ClientId, const char *pName);
58
59 void ShowTeamTop5(int ClientId, int Offset = 1);
60 void ShowPlayerTeamTop5(int ClientId, const char *pName, int Offset = 1);
61 void ShowTeamRank(int ClientId, const char *pName);
62
63 void ShowTopPoints(int ClientId, int Offset = 1);
64 void ShowPoints(int ClientId, const char *pName);
65
66 void ShowTimes(int ClientId, const char *pName, int Offset = 1);
67 void ShowTimes(int ClientId, int Offset = 1);
68
69 void RandomMap(int ClientId, int Stars);
70 void RandomUnfinishedMap(int ClientId, int Stars);
71
72 void SaveTeam(int ClientId, const char *pCode, const char *pServer);
73 void LoadTeam(const char *pCode, int ClientId);
74 void GetSaves(int ClientId);
75};
76
77#endif // GAME_SERVER_SCORE_H
78