| 163 | } |
| 164 | |
| 165 | void 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 | |
| 190 | void CScore::SaveTeamScore(int Team, int *pClientIds, unsigned int Size, int TimeTicks, const char *pTimestamp) |
| 191 | { |
no test coverage detected