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-07-04 17:53:27 +00:00
|
|
|
#include <game/prng.h>
|
|
|
|
|
2021-11-24 12:09:07 +00:00
|
|
|
#include "scoreworker.h"
|
2010-08-20 17:45:09 +00:00
|
|
|
|
2022-06-17 17:54:10 +00:00
|
|
|
class CDbConnectionPool;
|
2020-07-04 17:53:27 +00:00
|
|
|
class CGameContext;
|
2022-06-17 17:54:10 +00:00
|
|
|
class IDbConnection;
|
|
|
|
class IServer;
|
|
|
|
struct ISqlData;
|
2020-07-04 17:53:27 +00:00
|
|
|
|
|
|
|
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;
|
|
|
|
|
2022-06-11 19:38:18 +00:00
|
|
|
std::vector<std::string> m_vWordlist;
|
2020-07-04 17:53:27 +00:00
|
|
|
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
|
|
|
|
2022-12-31 11:23:21 +00:00
|
|
|
void LoadBestTime();
|
2020-07-04 17:53:27 +00:00
|
|
|
void MapInfo(int ClientID, const char *pMapName);
|
|
|
|
void MapVote(int ClientID, const char *pMapName);
|
2022-06-08 15:08:12 +00:00
|
|
|
void LoadPlayerData(int ClientID, const char *pName = "");
|
Mark parameters as `const` when possible
According to cppchecker's `constParameter` error:
```
src\engine\gfx\image_manipulation.cpp:7:58: style: Parameter 'pSrc' can be declared as pointer to const [constParameter]
static void Dilate(int w, int h, int BPP, unsigned char *pSrc, unsigned char *pDest, unsigned char AlphaThreshold = TW_DILATE_ALPHA_THRESHOLD)
^
src\engine\gfx\image_manipulation.cpp:58:67: style: Parameter 'pSrc' can be declared as pointer to const [constParameter]
static void CopyColorValues(int w, int h, int BPP, unsigned char *pSrc, unsigned char *pDest)
^
src\engine\shared\network_conn.cpp:241:42: style: Parameter 'Addr' can be declared as reference to const [constParameter]
void CNetConnection::DirectInit(NETADDR &Addr, SECURITY_TOKEN SecurityToken, SECURITY_TOKEN Token, bool Sixup)
^
src\base\system.cpp:4060:71: style: Parameter 'random' can be declared as pointer to const [constParameter]
void generate_password(char *buffer, unsigned length, unsigned short *random, unsigned random_length)
^
src\engine\client\backend\vulkan\backend_vulkan.cpp:263:38: style: Parameter 'AllocatedMemory' can be declared as reference to const [constParameter]
void Free(SMemoryHeapQueueElement &AllocatedMemory)
^
src\engine\client\backend\vulkan\backend_vulkan.cpp:1708:47: style: Parameter 'ImgExtent' can be declared as reference to const [constParameter]
static size_t ImageMipLevelCount(VkExtent3D &ImgExtent)
^
src\engine\client\backend\vulkan\backend_vulkan.cpp:2801:29: style: Parameter 'Image' can be declared as reference to const [constParameter]
void ImageBarrier(VkImage &Image, size_t MipMapBase, size_t MipMapCount, size_t LayerBase, size_t LayerCount, VkFormat Format, VkImageLayout OldLayout, VkImageLayout NewLayout)
^
src\engine\client\backend\vulkan\backend_vulkan.cpp:6495:46: style: Parameter 'ExecBuffer' can be declared as reference to const [constParameter]
void Cmd_Clear(SRenderCommandExecuteBuffer &ExecBuffer, const CCommandBuffer::SCommand_Clear *pCommand)
^
src\game\client\components\skins.cpp:83:72: style: Parameter 'pImg' can be declared as pointer to const [constParameter]
static void CheckMetrics(CSkin::SSkinMetricVariable &Metrics, uint8_t *pImg, int ImgWidth, int ImgX, int ImgY, int CheckWidth, int CheckHeight)
^
src\game\client\prediction\entities\character.h:106:37: style: Parameter 'pNewInput' can be declared as pointer to const [constParameter]
void SetInput(CNetObj_PlayerInput *pNewInput)
^
src\game\client\prediction\gameworld.cpp:245:106: style: Parameter 'pNotThis' can be declared as pointer to const [constParameter]
CCharacter *CGameWorld::IntersectCharacter(vec2 Pos0, vec2 Pos1, float Radius, vec2 &NewPos, CCharacter *pNotThis, int CollideWith, class CCharacter *pThisOnly)
^
src\game\client\prediction\gameworld.cpp:245:151: style: Parameter 'pThisOnly' can be declared as pointer to const [constParameter]
CCharacter *CGameWorld::IntersectCharacter(vec2 Pos0, vec2 Pos1, float Radius, vec2 &NewPos, CCharacter *pNotThis, int CollideWith, class CCharacter *pThisOnly)
^
src\game\client\prediction\gameworld.cpp:283:116: style: Parameter 'pNotThis' can be declared as pointer to const [constParameter]
std::list<class CCharacter *> CGameWorld::IntersectedCharacters(vec2 Pos0, vec2 Pos1, float Radius, class CEntity *pNotThis)
^
src\game\client\ui.cpp:522:180: style: Parameter 'pReadCursor' can be declared as pointer to const [constParameter]
void CUI::DoLabel(CUIElement::SUIElementRect &RectEl, const CUIRect *pRect, const char *pText, float Size, int Align, const SLabelProperties &LabelProps, int StrLen, CTextCursor *pReadCursor)
^
src\game\client\ui_scrollregion.cpp:23:86: style: Parameter 'pParams' can be declared as pointer to const [constParameter]
void CScrollRegion::Begin(CUIRect *pClipRect, vec2 *pOutOffset, CScrollRegionParams *pParams)
^
src\game\server\scoreworker.h:239:29: style: Parameter 'aTimeCp' can be declared as const array [constParameter]
void Set(float Time, float aTimeCp[NUM_CHECKPOINTS])
^
src\game\server\score.cpp:135:80: style: Parameter 'aTimeCp' can be declared as const array [constParameter]
void CScore::SaveScore(int ClientID, float Time, const char *pTimestamp, float aTimeCp[NUM_CHECKPOINTS], bool NotEligible)
^
src\game\server\teeinfo.cpp:40:57: style: Parameter 'pUseCustomColors' can be declared as pointer to const [constParameter]
CTeeInfo::CTeeInfo(const char *apSkinPartNames[6], int *pUseCustomColors, int *pSkinPartColors)
^
src\game\server\teeinfo.cpp:40:80: style: Parameter 'pSkinPartColors' can be declared as pointer to const [constParameter]
CTeeInfo::CTeeInfo(const char *apSkinPartNames[6], int *pUseCustomColors, int *pSkinPartColors)
^
```
2022-11-13 14:32:53 +00:00
|
|
|
void SaveScore(int ClientID, float Time, const char *pTimestamp, const float aTimeCp[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
|