| 1 | #ifndef GAME_SERVER_SCORE_H |
| 2 | #define GAME_SERVER_SCORE_H |
| 3 | |
| 4 | #include "scoreworker.h" |
| 5 | |
| 6 | #include <game/prng.h> |
| 7 | |
| 8 | class CDbConnectionPool; |
| 9 | class CGameContext; |
| 10 | class IDbConnection; |
| 11 | class IServer; |
| 12 | struct ISqlData; |
| 13 | |
| 14 | class 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 | |
| 41 | public: |
| 42 | CScore(CGameContext *pGameServer, CDbConnectionPool *pPool); |
| 43 | |
| 44 | CPlayerData *PlayerData(int Id) { return &m_aPlayerData[Id]; } |
| 45 | |
| 46 | void LoadBestTime(); |
| 47 | void MapInfo(int ClientId, const char *pMapName); |
| 48 | void MapVote(int ClientId, const char *pMapName); |
| 49 | void LoadPlayerData(int ClientId, const char *pName = "" ); |
| 50 | void LoadPlayerTimeCp(int ClientId, const char *pName = "" ); |
| 51 | void SaveScore(int ClientId, int TimeTicks, const char *pTimestamp, const float aTimeCp[NUM_CHECKPOINTS], bool NotEligible); |
| 52 | |
| 53 | void SaveTeamScore(int Team, int *pClientIds, unsigned int Size, int TimeTicks, const char *pTimestamp); |
| 54 | |
| 55 | void ShowTop(int ClientId, int Offset = 1); |
| 56 | void ShowRank(int ClientId, const char *pName); |
| 57 | |
| 58 | void ShowTeamTop5(int ClientId, int Offset = 1); |
| 59 | void ShowPlayerTeamTop5(int ClientId, const char *pName, int Offset = 1); |
| 60 | void ShowTeamRank(int ClientId, const char *pName); |
| 61 | |
| 62 | void ShowTopPoints(int ClientId, int Offset = 1); |
| 63 | void ShowPoints(int ClientId, const char *pName); |
| 64 | |
| 65 | void ShowTimes(int ClientId, const char *pName, int Offset = 1); |
| 66 | void ShowTimes(int ClientId, int Offset = 1); |
| 67 | |
| 68 | void RandomMap(int ClientId, int MinStars, int MaxStars); |
| 69 | void RandomUnfinishedMap(int ClientId, int MinStars, int MaxStars); |
| 70 | |
| 71 | void SaveTeam(int ClientId, const char *pCode, const char *pServer); |
| 72 | void LoadTeam(const char *pCode, int ClientId); |
| 73 | void GetSaves(int ClientId); |
| 74 | }; |
| 75 | |
| 76 | #endif // GAME_SERVER_SCORE_H |
| 77 | |