MCPcopy Create free account
hub / github.com/ddnet/ddnet / SaveScore

Method SaveScore

src/game/server/score.cpp:165–188  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

163}
164
165void CScore::SaveScore(int ClientId, int TimeTicks, const char *pTimestamp, const float aTimeCp[NUM_CHECKPOINTS], bool NotEligible)
166{
167 CConsole *pCon = (CConsole *)GameServer()->Console();
168 if(pCon->Cheated() || NotEligible)
169 return;
170
171 GameServer()->TeehistorianRecordPlayerFinish(ClientId, TimeTicks);
172
173 CPlayer *pCurPlayer = GameServer()->m_apPlayers[ClientId];
174 if(pCurPlayer->m_ScoreFinishResult != nullptr)
175 dbg_msg("sql", "WARNING: previous save score result didn't complete, overwriting it now");
176 pCurPlayer->m_ScoreFinishResult = std::make_shared<CScorePlayerResult>();
177 auto Tmp = std::make_unique<CSqlScoreData>(pCurPlayer->m_ScoreFinishResult);
178 str_copy(Tmp->m_aMap, GameServer()->Map()->BaseName(), sizeof(Tmp->m_aMap));
179 FormatUuid(GameServer()->GameUuid(), Tmp->m_aGameUuid, sizeof(Tmp->m_aGameUuid));
180 Tmp->m_ClientId = ClientId;
181 str_copy(Tmp->m_aName, Server()->ClientName(ClientId), sizeof(Tmp->m_aName));
182 Tmp->m_Time = (float)(TimeTicks) / (float)Server()->TickSpeed();
183 str_copy(Tmp->m_aTimestamp, pTimestamp, sizeof(Tmp->m_aTimestamp));
184 for(int i = 0; i < NUM_CHECKPOINTS; i++)
185 Tmp->m_aCurrentTimeCp[i] = aTimeCp[i];
186
187 m_pPool->ExecuteWrite(CScoreWorker::SaveScore, std::move(Tmp), "save score");
188}
189
190void CScore::SaveTeamScore(int Team, int *pClientIds, unsigned int Size, int TimeTicks, const char *pTimestamp)
191{

Callers 1

OnFinishMethod · 0.45

Calls 13

dbg_msgFunction · 0.85
FormatUuidFunction · 0.85
CheatedMethod · 0.80
GameUuidMethod · 0.80
ClientNameMethod · 0.80
TickSpeedMethod · 0.80
ExecuteWriteMethod · 0.80
str_copyFunction · 0.50
ServerClass · 0.50
ConsoleMethod · 0.45
BaseNameMethod · 0.45

Tested by

no test coverage detected