mirror of
https://github.com/ddnet/ddnet.git
synced 2024-11-10 10:08:18 +00:00
Merge #6213
6213: Fix scoreboard showing wrong best time r=Zwelf a=def- by requesting the best time again when it initially failed. This is still not perfectly accurate since a player on another server can get a better time, which will not get updated when the current server had no database problems. As reported by thekid36 on Discord: > The best time shown on the scoreboard on the turkish server on a > ddmax.Next map (mapname: 42) is 30min..while the best time should be 4 > min (it's correct on ger2 server) So the way it works is that the best time is loaded from database when loading map. Additionally it gets updated when a new finish is done. If the initial load failed, but a finish with 30 min is done on the server, we get this result <!-- What is the motivation for the changes of this pull request? --> <!-- Note that builds and other checks will be run for your change. Don't feel intimidated by failures in some of the checks. If you can't resolve them yourself, experienced devs can also resolve them before merging your pull request. --> ## Checklist - [ ] Tested the change ingame - [ ] Provided screenshots if it is a visual change - [ ] Tested in combination with possibly related configuration options - [ ] Written a unit test (especially base/) or added coverage to integration test - [ ] Considered possible null pointers and out of bounds array indexing - [ ] Changed no physics that affect existing maps - [ ] Tested the change with [ASan+UBSan or valgrind's memcheck](https://github.com/ddnet/ddnet/#using-addresssanitizer--undefinedbehavioursanitizer-or-valgrinds-memcheck) (optional) Co-authored-by: def <dennis@felsin9.de>
This commit is contained in:
commit
f0d2b9ab69
|
@ -15,7 +15,7 @@
|
|||
#define TEST_TYPE_NAME "TestDDraceNetwork"
|
||||
|
||||
CGameControllerDDRace::CGameControllerDDRace(class CGameContext *pGameServer) :
|
||||
IGameController(pGameServer), m_Teams(pGameServer), m_pInitResult(nullptr)
|
||||
IGameController(pGameServer), m_Teams(pGameServer), m_pLoadBestTimeResult(nullptr)
|
||||
{
|
||||
m_pGameType = g_Config.m_SvTestingCommands ? TEST_TYPE_NAME : GAME_TYPE_NAME;
|
||||
|
||||
|
@ -171,13 +171,21 @@ void CGameControllerDDRace::Tick()
|
|||
m_Teams.ProcessSaveTeam();
|
||||
m_Teams.Tick();
|
||||
|
||||
if(m_pInitResult != nullptr && m_pInitResult->m_Completed)
|
||||
if(m_pLoadBestTimeResult != nullptr && m_pLoadBestTimeResult->m_Completed)
|
||||
{
|
||||
if(m_pInitResult->m_Success)
|
||||
if(m_pLoadBestTimeResult->m_Success)
|
||||
{
|
||||
m_CurrentRecord = m_pInitResult->m_CurrentRecord;
|
||||
m_CurrentRecord = m_pLoadBestTimeResult->m_CurrentRecord;
|
||||
|
||||
for(int i = 0; i < MAX_CLIENTS; i++)
|
||||
{
|
||||
if(GameServer()->m_apPlayers[i] && GameServer()->m_apPlayers[i]->GetClientVersion() >= VERSION_DDRACE)
|
||||
{
|
||||
GameServer()->SendRecord(i);
|
||||
}
|
||||
}
|
||||
}
|
||||
m_pInitResult = nullptr;
|
||||
m_pLoadBestTimeResult = nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -8,7 +8,7 @@
|
|||
#include <map>
|
||||
#include <vector>
|
||||
|
||||
struct CScoreInitResult;
|
||||
struct CScoreLoadBestTimeResult;
|
||||
class CGameControllerDDRace : public IGameController
|
||||
{
|
||||
public:
|
||||
|
@ -40,6 +40,6 @@ public:
|
|||
std::map<int, std::vector<vec2>> m_TeleOuts;
|
||||
std::map<int, std::vector<vec2>> m_TeleCheckOuts;
|
||||
|
||||
std::shared_ptr<CScoreInitResult> m_pInitResult;
|
||||
std::shared_ptr<CScoreLoadBestTimeResult> m_pLoadBestTimeResult;
|
||||
};
|
||||
#endif // GAME_SERVER_GAMEMODES_DDRACE_H
|
||||
|
|
|
@ -73,11 +73,6 @@ CScore::CScore(CGameContext *pGameServer, CDbConnectionPool *pPool) :
|
|||
m_pGameServer(pGameServer),
|
||||
m_pServer(pGameServer->Server())
|
||||
{
|
||||
auto InitResult = std::make_shared<CScoreInitResult>();
|
||||
auto Tmp = std::make_unique<CSqlInitData>(InitResult);
|
||||
((CGameControllerDDRace *)(pGameServer->m_pController))->m_pInitResult = InitResult;
|
||||
str_copy(Tmp->m_aMap, g_Config.m_SvMap, sizeof(Tmp->m_aMap));
|
||||
|
||||
uint64_t aSeed[2];
|
||||
secure_random_fill(aSeed, sizeof(aSeed));
|
||||
m_Prng.Seed(aSeed);
|
||||
|
@ -109,8 +104,19 @@ CScore::CScore(CGameContext *pGameServer, CDbConnectionPool *pPool) :
|
|||
Server()->SetErrorShutdown("sql too few words in wordlist");
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
m_pPool->Execute(CScoreWorker::Init, std::move(Tmp), "load best time");
|
||||
void CScore::LoadBestTime()
|
||||
{
|
||||
if(((CGameControllerDDRace *)(m_pGameServer->m_pController))->m_pLoadBestTimeResult)
|
||||
return; // already in progress
|
||||
|
||||
auto LoadBestTimeResult = std::make_shared<CScoreLoadBestTimeResult>();
|
||||
((CGameControllerDDRace *)(m_pGameServer->m_pController))->m_pLoadBestTimeResult = LoadBestTimeResult;
|
||||
|
||||
auto Tmp = std::make_unique<CSqlLoadBestTimeData>(LoadBestTimeResult);
|
||||
str_copy(Tmp->m_aMap, g_Config.m_SvMap, sizeof(Tmp->m_aMap));
|
||||
m_pPool->Execute(CScoreWorker::LoadBestTime, std::move(Tmp), "load best time");
|
||||
}
|
||||
|
||||
void CScore::LoadPlayerData(int ClientID, const char *pName)
|
||||
|
|
|
@ -44,6 +44,7 @@ public:
|
|||
|
||||
CPlayerData *PlayerData(int ID) { return &m_aPlayerData[ID]; }
|
||||
|
||||
void LoadBestTime();
|
||||
void MapInfo(int ClientID, const char *pMapName);
|
||||
void MapVote(int ClientID, const char *pMapName);
|
||||
void LoadPlayerData(int ClientID, const char *pName = "");
|
||||
|
|
|
@ -94,10 +94,10 @@ bool CTeamrank::SamePlayers(const std::vector<std::string> *pvSortedNames)
|
|||
return true;
|
||||
}
|
||||
|
||||
bool CScoreWorker::Init(IDbConnection *pSqlServer, const ISqlData *pGameData, char *pError, int ErrorSize)
|
||||
bool CScoreWorker::LoadBestTime(IDbConnection *pSqlServer, const ISqlData *pGameData, char *pError, int ErrorSize)
|
||||
{
|
||||
const CSqlInitData *pData = dynamic_cast<const CSqlInitData *>(pGameData);
|
||||
CScoreInitResult *pResult = dynamic_cast<CScoreInitResult *>(pGameData->m_pResult.get());
|
||||
const auto *pData = dynamic_cast<const CSqlLoadBestTimeData *>(pGameData);
|
||||
auto *pResult = dynamic_cast<CScoreLoadBestTimeResult *>(pGameData->m_pResult.get());
|
||||
|
||||
char aBuf[512];
|
||||
// get the best time
|
||||
|
@ -126,8 +126,8 @@ bool CScoreWorker::Init(IDbConnection *pSqlServer, const ISqlData *pGameData, ch
|
|||
// update stuff
|
||||
bool CScoreWorker::LoadPlayerData(IDbConnection *pSqlServer, const ISqlData *pGameData, char *pError, int ErrorSize)
|
||||
{
|
||||
const CSqlPlayerRequest *pData = dynamic_cast<const CSqlPlayerRequest *>(pGameData);
|
||||
CScorePlayerResult *pResult = dynamic_cast<CScorePlayerResult *>(pGameData->m_pResult.get());
|
||||
const auto *pData = dynamic_cast<const CSqlPlayerRequest *>(pGameData);
|
||||
auto *pResult = dynamic_cast<CScorePlayerResult *>(pGameData->m_pResult.get());
|
||||
pResult->SetVariant(CScorePlayerResult::PLAYER_INFO);
|
||||
|
||||
char aBuf[512];
|
||||
|
@ -209,8 +209,8 @@ bool CScoreWorker::LoadPlayerData(IDbConnection *pSqlServer, const ISqlData *pGa
|
|||
|
||||
bool CScoreWorker::MapVote(IDbConnection *pSqlServer, const ISqlData *pGameData, char *pError, int ErrorSize)
|
||||
{
|
||||
const CSqlPlayerRequest *pData = dynamic_cast<const CSqlPlayerRequest *>(pGameData);
|
||||
CScorePlayerResult *pResult = dynamic_cast<CScorePlayerResult *>(pGameData->m_pResult.get());
|
||||
const auto *pData = dynamic_cast<const CSqlPlayerRequest *>(pGameData);
|
||||
auto *pResult = dynamic_cast<CScorePlayerResult *>(pGameData->m_pResult.get());
|
||||
auto *paMessages = pResult->m_Data.m_aaMessages;
|
||||
|
||||
char aFuzzyMap[128];
|
||||
|
@ -270,8 +270,8 @@ bool CScoreWorker::MapVote(IDbConnection *pSqlServer, const ISqlData *pGameData,
|
|||
|
||||
bool CScoreWorker::MapInfo(IDbConnection *pSqlServer, const ISqlData *pGameData, char *pError, int ErrorSize)
|
||||
{
|
||||
const CSqlPlayerRequest *pData = dynamic_cast<const CSqlPlayerRequest *>(pGameData);
|
||||
CScorePlayerResult *pResult = dynamic_cast<CScorePlayerResult *>(pGameData->m_pResult.get());
|
||||
const auto *pData = dynamic_cast<const CSqlPlayerRequest *>(pGameData);
|
||||
auto *pResult = dynamic_cast<CScorePlayerResult *>(pGameData->m_pResult.get());
|
||||
|
||||
char aFuzzyMap[128];
|
||||
str_copy(aFuzzyMap, pData->m_aName, sizeof(aFuzzyMap));
|
||||
|
@ -396,8 +396,8 @@ bool CScoreWorker::MapInfo(IDbConnection *pSqlServer, const ISqlData *pGameData,
|
|||
|
||||
bool CScoreWorker::SaveScore(IDbConnection *pSqlServer, const ISqlData *pGameData, Write w, char *pError, int ErrorSize)
|
||||
{
|
||||
const CSqlScoreData *pData = dynamic_cast<const CSqlScoreData *>(pGameData);
|
||||
CScorePlayerResult *pResult = dynamic_cast<CScorePlayerResult *>(pGameData->m_pResult.get());
|
||||
const auto *pData = dynamic_cast<const CSqlScoreData *>(pGameData);
|
||||
auto *pResult = dynamic_cast<CScorePlayerResult *>(pGameData->m_pResult.get());
|
||||
auto *paMessages = pResult->m_Data.m_aaMessages;
|
||||
|
||||
char aBuf[1024];
|
||||
|
@ -555,7 +555,7 @@ bool CScoreWorker::SaveScore(IDbConnection *pSqlServer, const ISqlData *pGameDat
|
|||
|
||||
bool CScoreWorker::SaveTeamScore(IDbConnection *pSqlServer, const ISqlData *pGameData, Write w, char *pError, int ErrorSize)
|
||||
{
|
||||
const CSqlTeamScoreData *pData = dynamic_cast<const CSqlTeamScoreData *>(pGameData);
|
||||
const auto *pData = dynamic_cast<const CSqlTeamScoreData *>(pGameData);
|
||||
|
||||
char aBuf[512];
|
||||
|
||||
|
@ -724,8 +724,8 @@ bool CScoreWorker::SaveTeamScore(IDbConnection *pSqlServer, const ISqlData *pGam
|
|||
|
||||
bool CScoreWorker::ShowRank(IDbConnection *pSqlServer, const ISqlData *pGameData, char *pError, int ErrorSize)
|
||||
{
|
||||
const CSqlPlayerRequest *pData = dynamic_cast<const CSqlPlayerRequest *>(pGameData);
|
||||
CScorePlayerResult *pResult = dynamic_cast<CScorePlayerResult *>(pGameData->m_pResult.get());
|
||||
const auto *pData = dynamic_cast<const CSqlPlayerRequest *>(pGameData);
|
||||
auto *pResult = dynamic_cast<CScorePlayerResult *>(pGameData->m_pResult.get());
|
||||
|
||||
char aServerLike[16];
|
||||
str_format(aServerLike, sizeof(aServerLike), "%%%s%%", pData->m_aServer);
|
||||
|
@ -828,8 +828,8 @@ bool CScoreWorker::ShowRank(IDbConnection *pSqlServer, const ISqlData *pGameData
|
|||
|
||||
bool CScoreWorker::ShowTeamRank(IDbConnection *pSqlServer, const ISqlData *pGameData, char *pError, int ErrorSize)
|
||||
{
|
||||
const CSqlPlayerRequest *pData = dynamic_cast<const CSqlPlayerRequest *>(pGameData);
|
||||
CScorePlayerResult *pResult = dynamic_cast<CScorePlayerResult *>(pGameData->m_pResult.get());
|
||||
const auto *pData = dynamic_cast<const CSqlPlayerRequest *>(pGameData);
|
||||
auto *pResult = dynamic_cast<CScorePlayerResult *>(pGameData->m_pResult.get());
|
||||
|
||||
// check sort method
|
||||
char aBuf[2400];
|
||||
|
@ -911,8 +911,8 @@ bool CScoreWorker::ShowTeamRank(IDbConnection *pSqlServer, const ISqlData *pGame
|
|||
|
||||
bool CScoreWorker::ShowTop(IDbConnection *pSqlServer, const ISqlData *pGameData, char *pError, int ErrorSize)
|
||||
{
|
||||
const CSqlPlayerRequest *pData = dynamic_cast<const CSqlPlayerRequest *>(pGameData);
|
||||
CScorePlayerResult *pResult = dynamic_cast<CScorePlayerResult *>(pGameData->m_pResult.get());
|
||||
const auto *pData = dynamic_cast<const CSqlPlayerRequest *>(pGameData);
|
||||
auto *pResult = dynamic_cast<CScorePlayerResult *>(pGameData->m_pResult.get());
|
||||
|
||||
int LimitStart = maximum(abs(pData->m_Offset) - 1, 0);
|
||||
const char *pOrder = pData->m_Offset >= 0 ? "ASC" : "DESC";
|
||||
|
@ -998,8 +998,8 @@ bool CScoreWorker::ShowTop(IDbConnection *pSqlServer, const ISqlData *pGameData,
|
|||
|
||||
bool CScoreWorker::ShowTeamTop5(IDbConnection *pSqlServer, const ISqlData *pGameData, char *pError, int ErrorSize)
|
||||
{
|
||||
const CSqlPlayerRequest *pData = dynamic_cast<const CSqlPlayerRequest *>(pGameData);
|
||||
CScorePlayerResult *pResult = dynamic_cast<CScorePlayerResult *>(pGameData->m_pResult.get());
|
||||
const auto *pData = dynamic_cast<const CSqlPlayerRequest *>(pGameData);
|
||||
auto *pResult = dynamic_cast<CScorePlayerResult *>(pGameData->m_pResult.get());
|
||||
auto *paMessages = pResult->m_Data.m_aaMessages;
|
||||
|
||||
int LimitStart = maximum(abs(pData->m_Offset) - 1, 0);
|
||||
|
@ -1085,8 +1085,8 @@ bool CScoreWorker::ShowTeamTop5(IDbConnection *pSqlServer, const ISqlData *pGame
|
|||
|
||||
bool CScoreWorker::ShowPlayerTeamTop5(IDbConnection *pSqlServer, const ISqlData *pGameData, char *pError, int ErrorSize)
|
||||
{
|
||||
const CSqlPlayerRequest *pData = dynamic_cast<const CSqlPlayerRequest *>(pGameData);
|
||||
CScorePlayerResult *pResult = dynamic_cast<CScorePlayerResult *>(pGameData->m_pResult.get());
|
||||
const auto *pData = dynamic_cast<const CSqlPlayerRequest *>(pGameData);
|
||||
auto *pResult = dynamic_cast<CScorePlayerResult *>(pGameData->m_pResult.get());
|
||||
auto *paMessages = pResult->m_Data.m_aaMessages;
|
||||
|
||||
int LimitStart = maximum(abs(pData->m_Offset) - 1, 0);
|
||||
|
@ -1177,8 +1177,8 @@ bool CScoreWorker::ShowPlayerTeamTop5(IDbConnection *pSqlServer, const ISqlData
|
|||
|
||||
bool CScoreWorker::ShowTimes(IDbConnection *pSqlServer, const ISqlData *pGameData, char *pError, int ErrorSize)
|
||||
{
|
||||
const CSqlPlayerRequest *pData = dynamic_cast<const CSqlPlayerRequest *>(pGameData);
|
||||
CScorePlayerResult *pResult = dynamic_cast<CScorePlayerResult *>(pGameData->m_pResult.get());
|
||||
const auto *pData = dynamic_cast<const CSqlPlayerRequest *>(pGameData);
|
||||
auto *pResult = dynamic_cast<CScorePlayerResult *>(pGameData->m_pResult.get());
|
||||
auto *paMessages = pResult->m_Data.m_aaMessages;
|
||||
|
||||
int LimitStart = maximum(abs(pData->m_Offset) - 1, 0);
|
||||
|
@ -1292,8 +1292,8 @@ bool CScoreWorker::ShowTimes(IDbConnection *pSqlServer, const ISqlData *pGameDat
|
|||
|
||||
bool CScoreWorker::ShowPoints(IDbConnection *pSqlServer, const ISqlData *pGameData, char *pError, int ErrorSize)
|
||||
{
|
||||
const CSqlPlayerRequest *pData = dynamic_cast<const CSqlPlayerRequest *>(pGameData);
|
||||
CScorePlayerResult *pResult = dynamic_cast<CScorePlayerResult *>(pGameData->m_pResult.get());
|
||||
const auto *pData = dynamic_cast<const CSqlPlayerRequest *>(pGameData);
|
||||
auto *pResult = dynamic_cast<CScorePlayerResult *>(pGameData->m_pResult.get());
|
||||
auto *paMessages = pResult->m_Data.m_aaMessages;
|
||||
|
||||
char aBuf[512];
|
||||
|
@ -1337,8 +1337,8 @@ bool CScoreWorker::ShowPoints(IDbConnection *pSqlServer, const ISqlData *pGameDa
|
|||
|
||||
bool CScoreWorker::ShowTopPoints(IDbConnection *pSqlServer, const ISqlData *pGameData, char *pError, int ErrorSize)
|
||||
{
|
||||
const CSqlPlayerRequest *pData = dynamic_cast<const CSqlPlayerRequest *>(pGameData);
|
||||
CScorePlayerResult *pResult = dynamic_cast<CScorePlayerResult *>(pGameData->m_pResult.get());
|
||||
const auto *pData = dynamic_cast<const CSqlPlayerRequest *>(pGameData);
|
||||
auto *pResult = dynamic_cast<CScorePlayerResult *>(pGameData->m_pResult.get());
|
||||
auto *paMessages = pResult->m_Data.m_aaMessages;
|
||||
|
||||
int LimitStart = maximum(pData->m_Offset - 1, 0);
|
||||
|
@ -1386,8 +1386,8 @@ bool CScoreWorker::ShowTopPoints(IDbConnection *pSqlServer, const ISqlData *pGam
|
|||
|
||||
bool CScoreWorker::RandomMap(IDbConnection *pSqlServer, const ISqlData *pGameData, char *pError, int ErrorSize)
|
||||
{
|
||||
const CSqlRandomMapRequest *pData = dynamic_cast<const CSqlRandomMapRequest *>(pGameData);
|
||||
CScoreRandomMapResult *pResult = dynamic_cast<CScoreRandomMapResult *>(pGameData->m_pResult.get());
|
||||
const auto *pData = dynamic_cast<const CSqlRandomMapRequest *>(pGameData);
|
||||
auto *pResult = dynamic_cast<CScoreRandomMapResult *>(pGameData->m_pResult.get());
|
||||
|
||||
char aBuf[512];
|
||||
if(0 <= pData->m_Stars && pData->m_Stars <= 5)
|
||||
|
@ -1436,8 +1436,8 @@ bool CScoreWorker::RandomMap(IDbConnection *pSqlServer, const ISqlData *pGameDat
|
|||
|
||||
bool CScoreWorker::RandomUnfinishedMap(IDbConnection *pSqlServer, const ISqlData *pGameData, char *pError, int ErrorSize)
|
||||
{
|
||||
const CSqlRandomMapRequest *pData = dynamic_cast<const CSqlRandomMapRequest *>(pGameData);
|
||||
CScoreRandomMapResult *pResult = dynamic_cast<CScoreRandomMapResult *>(pGameData->m_pResult.get());
|
||||
const auto *pData = dynamic_cast<const CSqlRandomMapRequest *>(pGameData);
|
||||
auto *pResult = dynamic_cast<CScoreRandomMapResult *>(pGameData->m_pResult.get());
|
||||
|
||||
char aBuf[512];
|
||||
if(pData->m_Stars >= 0)
|
||||
|
@ -1500,8 +1500,8 @@ bool CScoreWorker::RandomUnfinishedMap(IDbConnection *pSqlServer, const ISqlData
|
|||
|
||||
bool CScoreWorker::SaveTeam(IDbConnection *pSqlServer, const ISqlData *pGameData, Write w, char *pError, int ErrorSize)
|
||||
{
|
||||
const CSqlTeamSave *pData = dynamic_cast<const CSqlTeamSave *>(pGameData);
|
||||
CScoreSaveResult *pResult = dynamic_cast<CScoreSaveResult *>(pGameData->m_pResult.get());
|
||||
const auto *pData = dynamic_cast<const CSqlTeamSave *>(pGameData);
|
||||
auto *pResult = dynamic_cast<CScoreSaveResult *>(pGameData->m_pResult.get());
|
||||
|
||||
if(w == Write::NORMAL_SUCCEEDED)
|
||||
{
|
||||
|
@ -1647,8 +1647,8 @@ bool CScoreWorker::LoadTeam(IDbConnection *pSqlServer, const ISqlData *pGameData
|
|||
{
|
||||
if(w == Write::NORMAL_SUCCEEDED || Write::BACKUP_FIRST)
|
||||
return false;
|
||||
const CSqlTeamLoad *pData = dynamic_cast<const CSqlTeamLoad *>(pGameData);
|
||||
CScoreSaveResult *pResult = dynamic_cast<CScoreSaveResult *>(pGameData->m_pResult.get());
|
||||
const auto *pData = dynamic_cast<const CSqlTeamLoad *>(pGameData);
|
||||
auto *pResult = dynamic_cast<CScoreSaveResult *>(pGameData->m_pResult.get());
|
||||
pResult->m_Status = CScoreSaveResult::LOAD_FAILED;
|
||||
|
||||
char aCurrentTimestamp[512];
|
||||
|
@ -1775,8 +1775,8 @@ bool CScoreWorker::LoadTeam(IDbConnection *pSqlServer, const ISqlData *pGameData
|
|||
|
||||
bool CScoreWorker::GetSaves(IDbConnection *pSqlServer, const ISqlData *pGameData, char *pError, int ErrorSize)
|
||||
{
|
||||
const CSqlPlayerRequest *pData = dynamic_cast<const CSqlPlayerRequest *>(pGameData);
|
||||
CScorePlayerResult *pResult = dynamic_cast<CScorePlayerResult *>(pGameData->m_pResult.get());
|
||||
const auto *pData = dynamic_cast<const CSqlPlayerRequest *>(pGameData);
|
||||
auto *pResult = dynamic_cast<CScorePlayerResult *>(pGameData->m_pResult.get());
|
||||
auto *paMessages = pResult->m_Data.m_aaMessages;
|
||||
|
||||
char aSaveLike[128] = "";
|
||||
|
|
|
@ -62,18 +62,18 @@ struct CScorePlayerResult : ISqlResult
|
|||
void SetVariant(Variant v);
|
||||
};
|
||||
|
||||
struct CScoreInitResult : ISqlResult
|
||||
struct CScoreLoadBestTimeResult : ISqlResult
|
||||
{
|
||||
CScoreInitResult() :
|
||||
CScoreLoadBestTimeResult() :
|
||||
m_CurrentRecord(0)
|
||||
{
|
||||
}
|
||||
float m_CurrentRecord;
|
||||
};
|
||||
|
||||
struct CSqlInitData : ISqlData
|
||||
struct CSqlLoadBestTimeData : ISqlData
|
||||
{
|
||||
CSqlInitData(std::shared_ptr<CScoreInitResult> pResult) :
|
||||
CSqlLoadBestTimeData(std::shared_ptr<CScoreLoadBestTimeResult> pResult) :
|
||||
ISqlData(std::move(pResult))
|
||||
{
|
||||
}
|
||||
|
@ -274,7 +274,7 @@ struct CTeamrank
|
|||
|
||||
struct CScoreWorker
|
||||
{
|
||||
static bool Init(IDbConnection *pSqlServer, const ISqlData *pGameData, char *pError, int ErrorSize);
|
||||
static bool LoadBestTime(IDbConnection *pSqlServer, const ISqlData *pGameData, char *pError, int ErrorSize);
|
||||
|
||||
static bool RandomMap(IDbConnection *pSqlServer, const ISqlData *pGameData, char *pError, int ErrorSize);
|
||||
static bool RandomUnfinishedMap(IDbConnection *pSqlServer, const ISqlData *pGameData, char *pError, int ErrorSize);
|
||||
|
|
|
@ -779,7 +779,11 @@ void CGameTeams::OnFinish(CPlayer *Player, float Time, const char *pTimestamp)
|
|||
|
||||
bool NeedToSendNewServerRecord = false;
|
||||
// update server best time
|
||||
if(GameServer()->m_pController->m_CurrentRecord == 0 || Time < GameServer()->m_pController->m_CurrentRecord)
|
||||
if(GameServer()->m_pController->m_CurrentRecord == 0)
|
||||
{
|
||||
GameServer()->Score()->LoadBestTime();
|
||||
}
|
||||
else if(Time < GameServer()->m_pController->m_CurrentRecord)
|
||||
{
|
||||
// check for nameless
|
||||
if(g_Config.m_SvNamelessScore || !str_startswith(Server()->ClientName(ClientID), "nameless tee"))
|
||||
|
|
|
@ -41,7 +41,7 @@ struct Score : public testing::TestWithParam<IDbConnection *>
|
|||
Score()
|
||||
{
|
||||
Connect();
|
||||
Init();
|
||||
LoadBestTime();
|
||||
InsertMap();
|
||||
}
|
||||
|
||||
|
@ -68,11 +68,11 @@ struct Score : public testing::TestWithParam<IDbConnection *>
|
|||
ASSERT_FALSE(m_pConn->ExecuteUpdate(&NumInserted, m_aError, sizeof(m_aError))) << m_aError;
|
||||
}
|
||||
|
||||
void Init()
|
||||
void LoadBestTime()
|
||||
{
|
||||
CSqlInitData initData(std::make_shared<CScoreInitResult>());
|
||||
str_copy(initData.m_aMap, "Kobra 3", sizeof(initData.m_aMap));
|
||||
ASSERT_FALSE(CScoreWorker::Init(m_pConn, &initData, m_aError, sizeof(m_aError))) << m_aError;
|
||||
CSqlLoadBestTimeData loadBestTimeData(std::make_shared<CScoreLoadBestTimeResult>());
|
||||
str_copy(loadBestTimeData.m_aMap, "Kobra 3", sizeof(loadBestTimeData.m_aMap));
|
||||
ASSERT_FALSE(CScoreWorker::LoadBestTime(m_pConn, &loadBestTimeData, m_aError, sizeof(m_aError))) << m_aError;
|
||||
}
|
||||
|
||||
void InsertMap()
|
||||
|
|
Loading…
Reference in a new issue