From 498c2dbbcf5efd074528e9cb9feabde1fba565ae Mon Sep 17 00:00:00 2001 From: c0d3d3v Date: Tue, 5 Jul 2022 16:13:48 +0200 Subject: [PATCH] Renamed some time checkpoint related variables. Init some of the time checkpoint variables explicitly --- src/game/server/entities/character.cpp | 31 +++++++++++------- src/game/server/entities/character.h | 10 +++--- src/game/server/gamemodes/DDRace.cpp | 7 +++- src/game/server/player.cpp | 2 +- src/game/server/save.cpp | 44 +++++++++++++------------- src/game/server/save.h | 8 ++--- src/game/server/score.cpp | 4 +-- src/game/server/score.h | 2 +- src/game/server/scoreworker.cpp | 24 +++++++------- src/game/server/scoreworker.h | 14 ++++---- src/game/server/teams.cpp | 14 ++++---- src/game/server/teams.h | 4 +-- src/test/score.cpp | 8 ++--- 13 files changed, 93 insertions(+), 79 deletions(-) diff --git a/src/game/server/entities/character.cpp b/src/game/server/entities/character.cpp index 10d199c03..906cf1fdb 100644 --- a/src/game/server/entities/character.cpp +++ b/src/game/server/entities/character.cpp @@ -35,6 +35,13 @@ CCharacter::CCharacter(CGameWorld *pWorld, CNetObj_PlayerInput LastInput) : m_Input.m_TargetY = -1; m_LatestPrevPrevInput = m_LatestPrevInput = m_LatestInput = m_PrevInput = m_SavedInput = m_Input; + + m_LastTimeCp = -1; + m_LastTimeCpBroadcasted = -1; + for(float &CurrentTimeCp : m_aCurrentTimeCp) + { + CurrentTimeCp = 0.0f; + } } void CCharacter::Reset() @@ -1226,15 +1233,15 @@ void CCharacter::HandleBroadcast() { CPlayerData *pData = GameServer()->Score()->PlayerData(m_pPlayer->GetCID()); - if(m_DDRaceState == DDRACE_STARTED && m_CpLastBroadcast != m_CpActive && - m_CpActive > -1 && m_CpTick > Server()->Tick() && m_pPlayer->GetClientVersion() == VERSION_VANILLA && - pData->m_BestTime && pData->m_aBestCpTime[m_CpActive] != 0) + if(m_DDRaceState == DDRACE_STARTED && m_pPlayer->GetClientVersion() == VERSION_VANILLA && + m_LastTimeCpBroadcasted != m_LastTimeCp && m_LastTimeCp > -1 && + m_TimeCpBroadcastEndTick > Server()->Tick() && pData->m_BestTime && pData->m_aBestTimeCp[m_LastTimeCp] != 0) { char aBroadcast[128]; - float Diff = m_CpCurrent[m_CpActive] - pData->m_aBestCpTime[m_CpActive]; + float Diff = m_aCurrentTimeCp[m_LastTimeCp] - pData->m_aBestTimeCp[m_LastTimeCp]; str_format(aBroadcast, sizeof(aBroadcast), "Checkpoint | Diff : %+5.2f", Diff); GameServer()->SendBroadcast(aBroadcast, m_pPlayer->GetCID()); - m_CpLastBroadcast = m_CpActive; + m_LastTimeCpBroadcasted = m_LastTimeCp; m_LastBroadcast = Server()->Tick(); } else if((m_pPlayer->m_TimerType == CPlayer::TIMERTYPE_BROADCAST || m_pPlayer->m_TimerType == CPlayer::TIMERTYPE_GAMETIMER_AND_BROADCAST) && m_DDRaceState == DDRACE_STARTED && m_LastBroadcast + Server()->TickSpeed() * g_Config.m_SvTimeInBroadcastInterval <= Server()->Tick()) @@ -1243,7 +1250,7 @@ void CCharacter::HandleBroadcast() int Time = (int64_t)100 * ((float)(Server()->Tick() - m_StartTime) / ((float)Server()->TickSpeed())); str_time(Time, TIME_HOURS, aBuf, sizeof(aBuf)); GameServer()->SendBroadcast(aBuf, m_pPlayer->GetCID(), false); - m_CpLastBroadcast = m_CpActive; + m_LastTimeCpBroadcasted = m_LastTimeCp; m_LastBroadcast = Server()->Tick(); } } @@ -1343,21 +1350,21 @@ bool CCharacter::IsSwitchActiveCb(int Number, void *pUser) void CCharacter::SetTimeCheckpoint(int TimeCheckpoint) { - if(TimeCheckpoint != -1 && m_DDRaceState == DDRACE_STARTED && TimeCheckpoint > m_CpActive) + if(TimeCheckpoint != -1 && m_DDRaceState == DDRACE_STARTED && TimeCheckpoint > m_LastTimeCp) { - m_CpActive = TimeCheckpoint; - m_CpCurrent[TimeCheckpoint] = m_Time; - m_CpTick = Server()->Tick() + Server()->TickSpeed() * 2; + m_LastTimeCp = TimeCheckpoint; + m_aCurrentTimeCp[TimeCheckpoint] = m_Time; + m_TimeCpBroadcastEndTick = Server()->Tick() + Server()->TickSpeed() * 2; if(m_pPlayer->GetClientVersion() >= VERSION_DDRACE) { CPlayerData *pData = GameServer()->Score()->PlayerData(m_pPlayer->GetCID()); - if(pData->m_BestTime && pData->m_aBestCpTime[m_CpActive] != 0 && m_CpActive != -1) + if(pData->m_BestTime && pData->m_aBestTimeCp[m_LastTimeCp] != 0 && m_LastTimeCp != -1) { CNetMsg_Sv_DDRaceTime Msg; Msg.m_Time = (int)(m_Time * 100.0f); Msg.m_Check = 0; Msg.m_Finish = 0; - float Diff = (m_CpCurrent[m_CpActive] - pData->m_aBestCpTime[m_CpActive]) * 100; + float Diff = (m_aCurrentTimeCp[m_LastTimeCp] - pData->m_aBestTimeCp[m_LastTimeCp]) * 100; Msg.m_Check = (int)Diff; Server()->SendPackMsg(&Msg, MSGFLAG_VITAL, m_pPlayer->GetCID()); } diff --git a/src/game/server/entities/character.h b/src/game/server/entities/character.h index c829d6c5d..fca628606 100644 --- a/src/game/server/entities/character.h +++ b/src/game/server/entities/character.h @@ -204,10 +204,12 @@ public: int m_StartTime; vec2 m_PrevPos; int m_TeleCheckpoint; - int m_CpTick; - int m_CpActive; - int m_CpLastBroadcast; - float m_CpCurrent[25]; + + int m_TimeCpBroadcastEndTick; + int m_LastTimeCp; + int m_LastTimeCpBroadcasted; + float m_aCurrentTimeCp[25]; + int m_TileIndex; int m_TileFIndex; diff --git a/src/game/server/gamemodes/DDRace.cpp b/src/game/server/gamemodes/DDRace.cpp index 264fbd871..21203b2f0 100644 --- a/src/game/server/gamemodes/DDRace.cpp +++ b/src/game/server/gamemodes/DDRace.cpp @@ -89,7 +89,12 @@ void CGameControllerDDRace::HandleCharacterTiles(CCharacter *pChr, int MapIndex) } m_Teams.OnCharacterStart(ClientID); - pChr->m_CpActive = -2; + pChr->m_LastTimeCp = -1; + pChr->m_LastTimeCpBroadcasted = -1; + for(float &CurrentTimeCp : pChr->m_aCurrentTimeCp) + { + CurrentTimeCp = 0.0f; + } } // finish diff --git a/src/game/server/player.cpp b/src/game/server/player.cpp index a8482396c..b37eff6a5 100644 --- a/src/game/server/player.cpp +++ b/src/game/server/player.cpp @@ -894,7 +894,7 @@ void CPlayer::ProcessScoreResult(CScorePlayerResult &Result) GameServer()->CallVote(m_ClientID, Result.m_Data.m_MapVote.m_aMap, aCmd, "/map", aChatmsg); break; case CScorePlayerResult::PLAYER_INFO: - GameServer()->Score()->PlayerData(m_ClientID)->Set(Result.m_Data.m_Info.m_Time, Result.m_Data.m_Info.m_CpTime); + GameServer()->Score()->PlayerData(m_ClientID)->Set(Result.m_Data.m_Info.m_Time, Result.m_Data.m_Info.m_aTimeCp); m_Score = Result.m_Data.m_Info.m_Score; m_HasFinishScore = Result.m_Data.m_Info.m_HasFinishScore; // -9999 stands for no time and isn't displayed in scoreboard, so diff --git a/src/game/server/save.cpp b/src/game/server/save.cpp index 754c66b90..609fb8a60 100644 --- a/src/game/server/save.cpp +++ b/src/game/server/save.cpp @@ -59,14 +59,14 @@ void CSaveTee::Save(CCharacter *pChr) m_TeleCheckpoint = pChr->m_TeleCheckpoint; m_LastPenalty = pChr->m_LastPenalty; - if(pChr->m_CpTick) - m_CpTime = pChr->Server()->Tick() - pChr->m_CpTick; + if(pChr->m_TimeCpBroadcastEndTick) + m_TimeCpBroadcastEndTime = pChr->Server()->Tick() - pChr->m_TimeCpBroadcastEndTick; - m_CpActive = pChr->m_CpActive; - m_CpLastBroadcast = pChr->m_CpLastBroadcast; + m_LastTimeCp = pChr->m_LastTimeCp; + m_LastTimeCpBroadcasted = pChr->m_LastTimeCpBroadcasted; for(int i = 0; i < 25; i++) - m_aCpCurrent[i] = pChr->m_CpCurrent[i]; + m_aCurrentTimeCp[i] = pChr->m_aCurrentTimeCp[i]; m_NotEligibleForFinish = pChr->m_pPlayer->m_NotEligibleForFinish; @@ -152,14 +152,14 @@ void CSaveTee::Load(CCharacter *pChr, int Team, bool IsSwap) pChr->m_TeleCheckpoint = m_TeleCheckpoint; pChr->m_LastPenalty = m_LastPenalty; - if(m_CpTime) - pChr->m_CpTick = pChr->Server()->Tick() - m_CpTime; + if(m_TimeCpBroadcastEndTime) + pChr->m_TimeCpBroadcastEndTick = pChr->Server()->Tick() - m_TimeCpBroadcastEndTime; - pChr->m_CpActive = m_CpActive; - pChr->m_CpLastBroadcast = m_CpLastBroadcast; + pChr->m_LastTimeCp = m_LastTimeCp; + pChr->m_LastTimeCpBroadcasted = m_LastTimeCpBroadcasted; for(int i = 0; i < 25; i++) - pChr->m_CpCurrent[i] = m_aCpCurrent[i]; + pChr->m_aCurrentTimeCp[i] = m_aCurrentTimeCp[i]; pChr->m_pPlayer->m_NotEligibleForFinish = pChr->m_pPlayer->m_NotEligibleForFinish || m_NotEligibleForFinish; @@ -278,12 +278,12 @@ char *CSaveTee::GetString(const CSaveTeam *pTeam) (int)m_HookPos.x, (int)m_HookPos.y, m_HookDir.x, m_HookDir.y, (int)m_HookTeleBase.x, (int)m_HookTeleBase.y, m_HookTick, m_HookState, // time checkpoints - m_CpTime, m_CpActive, m_CpLastBroadcast, - m_aCpCurrent[0], m_aCpCurrent[1], m_aCpCurrent[2], m_aCpCurrent[3], m_aCpCurrent[4], - m_aCpCurrent[5], m_aCpCurrent[6], m_aCpCurrent[7], m_aCpCurrent[8], m_aCpCurrent[9], - m_aCpCurrent[10], m_aCpCurrent[11], m_aCpCurrent[12], m_aCpCurrent[13], m_aCpCurrent[14], - m_aCpCurrent[15], m_aCpCurrent[16], m_aCpCurrent[17], m_aCpCurrent[18], m_aCpCurrent[19], - m_aCpCurrent[20], m_aCpCurrent[21], m_aCpCurrent[22], m_aCpCurrent[23], m_aCpCurrent[24], + m_TimeCpBroadcastEndTime, m_LastTimeCp, m_LastTimeCpBroadcasted, + m_aCurrentTimeCp[0], m_aCurrentTimeCp[1], m_aCurrentTimeCp[2], m_aCurrentTimeCp[3], m_aCurrentTimeCp[4], + m_aCurrentTimeCp[5], m_aCurrentTimeCp[6], m_aCurrentTimeCp[7], m_aCurrentTimeCp[8], m_aCurrentTimeCp[9], + m_aCurrentTimeCp[10], m_aCurrentTimeCp[11], m_aCurrentTimeCp[12], m_aCurrentTimeCp[13], m_aCurrentTimeCp[14], + m_aCurrentTimeCp[15], m_aCurrentTimeCp[16], m_aCurrentTimeCp[17], m_aCurrentTimeCp[18], m_aCurrentTimeCp[19], + m_aCurrentTimeCp[20], m_aCurrentTimeCp[21], m_aCurrentTimeCp[22], m_aCurrentTimeCp[23], m_aCurrentTimeCp[24], m_NotEligibleForFinish, m_HasTelegunGun, m_HasTelegunLaser, m_HasTelegunGrenade, m_aGameUuid, @@ -351,12 +351,12 @@ int CSaveTee::FromString(const char *String) &m_HookPos.x, &m_HookPos.y, &m_HookDir.x, &m_HookDir.y, &m_HookTeleBase.x, &m_HookTeleBase.y, &m_HookTick, &m_HookState, // time checkpoints - &m_CpTime, &m_CpActive, &m_CpLastBroadcast, - &m_aCpCurrent[0], &m_aCpCurrent[1], &m_aCpCurrent[2], &m_aCpCurrent[3], &m_aCpCurrent[4], - &m_aCpCurrent[5], &m_aCpCurrent[6], &m_aCpCurrent[7], &m_aCpCurrent[8], &m_aCpCurrent[9], - &m_aCpCurrent[10], &m_aCpCurrent[11], &m_aCpCurrent[12], &m_aCpCurrent[13], &m_aCpCurrent[14], - &m_aCpCurrent[15], &m_aCpCurrent[16], &m_aCpCurrent[17], &m_aCpCurrent[18], &m_aCpCurrent[19], - &m_aCpCurrent[20], &m_aCpCurrent[21], &m_aCpCurrent[22], &m_aCpCurrent[23], &m_aCpCurrent[24], + &m_TimeCpBroadcastEndTime, &m_LastTimeCp, &m_LastTimeCpBroadcasted, + &m_aCurrentTimeCp[0], &m_aCurrentTimeCp[1], &m_aCurrentTimeCp[2], &m_aCurrentTimeCp[3], &m_aCurrentTimeCp[4], + &m_aCurrentTimeCp[5], &m_aCurrentTimeCp[6], &m_aCurrentTimeCp[7], &m_aCurrentTimeCp[8], &m_aCurrentTimeCp[9], + &m_aCurrentTimeCp[10], &m_aCurrentTimeCp[11], &m_aCurrentTimeCp[12], &m_aCurrentTimeCp[13], &m_aCurrentTimeCp[14], + &m_aCurrentTimeCp[15], &m_aCurrentTimeCp[16], &m_aCurrentTimeCp[17], &m_aCurrentTimeCp[18], &m_aCurrentTimeCp[19], + &m_aCurrentTimeCp[20], &m_aCurrentTimeCp[21], &m_aCurrentTimeCp[22], &m_aCurrentTimeCp[23], &m_aCurrentTimeCp[24], &m_NotEligibleForFinish, &m_HasTelegunGun, &m_HasTelegunLaser, &m_HasTelegunGrenade, m_aGameUuid, diff --git a/src/game/server/save.h b/src/game/server/save.h index 2cb81b2f3..0965cfa6c 100644 --- a/src/game/server/save.h +++ b/src/game/server/save.h @@ -74,10 +74,10 @@ private: int m_TeleCheckpoint; int m_LastPenalty; - int m_CpTime; - int m_CpActive; - int m_CpLastBroadcast; - float m_aCpCurrent[25]; + int m_TimeCpBroadcastEndTime; + int m_LastTimeCp; + int m_LastTimeCpBroadcasted; + float m_aCurrentTimeCp[25]; int m_NotEligibleForFinish; diff --git a/src/game/server/score.cpp b/src/game/server/score.cpp index 6c9b788e7..568858617 100644 --- a/src/game/server/score.cpp +++ b/src/game/server/score.cpp @@ -132,7 +132,7 @@ void CScore::MapInfo(int ClientID, const char *MapName) ExecPlayerThread(CScoreWorker::MapInfo, "map info", ClientID, MapName, 0); } -void CScore::SaveScore(int ClientID, float Time, const char *pTimestamp, float CpTime[NUM_CHECKPOINTS], bool NotEligible) +void CScore::SaveScore(int ClientID, float Time, const char *pTimestamp, float aTimeCp[NUM_CHECKPOINTS], bool NotEligible) { CConsole *pCon = (CConsole *)GameServer()->Console(); if(pCon->m_Cheated || NotEligible) @@ -150,7 +150,7 @@ void CScore::SaveScore(int ClientID, float Time, const char *pTimestamp, float C Tmp->m_Time = Time; str_copy(Tmp->m_aTimestamp, pTimestamp, sizeof(Tmp->m_aTimestamp)); for(int i = 0; i < NUM_CHECKPOINTS; i++) - Tmp->m_aCpCurrent[i] = CpTime[i]; + Tmp->m_aCurrentTimeCp[i] = aTimeCp[i]; m_pPool->ExecuteWrite(CScoreWorker::SaveScore, std::move(Tmp), "save score"); } diff --git a/src/game/server/score.h b/src/game/server/score.h index 1c4928bdd..cab5b92c9 100644 --- a/src/game/server/score.h +++ b/src/game/server/score.h @@ -47,7 +47,7 @@ public: void MapInfo(int ClientID, const char *pMapName); void MapVote(int ClientID, const char *pMapName); void LoadPlayerData(int ClientID, const char *pName = ""); - void SaveScore(int ClientID, float Time, const char *pTimestamp, float aCpTime[NUM_CHECKPOINTS], bool NotEligible); + void SaveScore(int ClientID, float Time, const char *pTimestamp, float aTimeCp[NUM_CHECKPOINTS], bool NotEligible); void SaveTeamScore(int *pClientIDs, unsigned int Size, float Time, const char *pTimestamp); diff --git a/src/game/server/scoreworker.cpp b/src/game/server/scoreworker.cpp index 2767b5211..4bef8cd2b 100644 --- a/src/game/server/scoreworker.cpp +++ b/src/game/server/scoreworker.cpp @@ -41,8 +41,8 @@ void CScorePlayerResult::SetVariant(Variant v) m_Data.m_Info.m_Birthday = 0; m_Data.m_Info.m_HasFinishScore = false; m_Data.m_Info.m_Time = 0; - for(float &CpTime : m_Data.m_Info.m_CpTime) - CpTime = 0; + for(float &TimeCp : m_Data.m_Info.m_aTimeCp) + TimeCp = 0; } } @@ -171,7 +171,7 @@ bool CScoreWorker::LoadPlayerData(IDbConnection *pSqlServer, const ISqlData *pGa for(int i = 0; i < NUM_CHECKPOINTS; i++) { - pResult->m_Data.m_Info.m_CpTime[i] = pSqlServer->GetFloat(i + 2); + pResult->m_Data.m_Info.m_aTimeCp[i] = pSqlServer->GetFloat(i + 2); } } @@ -457,15 +457,15 @@ bool CScoreWorker::SaveScore(IDbConnection *pSqlServer, const ISqlData *pGameDat " ?, %s)", pSqlServer->InsertIgnore(), pSqlServer->GetPrefix(), pSqlServer->InsertTimestampAsUtc(), pData->m_Time, - pData->m_aCpCurrent[0], pData->m_aCpCurrent[1], pData->m_aCpCurrent[2], - pData->m_aCpCurrent[3], pData->m_aCpCurrent[4], pData->m_aCpCurrent[5], - pData->m_aCpCurrent[6], pData->m_aCpCurrent[7], pData->m_aCpCurrent[8], - pData->m_aCpCurrent[9], pData->m_aCpCurrent[10], pData->m_aCpCurrent[11], - pData->m_aCpCurrent[12], pData->m_aCpCurrent[13], pData->m_aCpCurrent[14], - pData->m_aCpCurrent[15], pData->m_aCpCurrent[16], pData->m_aCpCurrent[17], - pData->m_aCpCurrent[18], pData->m_aCpCurrent[19], pData->m_aCpCurrent[20], - pData->m_aCpCurrent[21], pData->m_aCpCurrent[22], pData->m_aCpCurrent[23], - pData->m_aCpCurrent[24], pSqlServer->False()); + pData->m_aCurrentTimeCp[0], pData->m_aCurrentTimeCp[1], pData->m_aCurrentTimeCp[2], + pData->m_aCurrentTimeCp[3], pData->m_aCurrentTimeCp[4], pData->m_aCurrentTimeCp[5], + pData->m_aCurrentTimeCp[6], pData->m_aCurrentTimeCp[7], pData->m_aCurrentTimeCp[8], + pData->m_aCurrentTimeCp[9], pData->m_aCurrentTimeCp[10], pData->m_aCurrentTimeCp[11], + pData->m_aCurrentTimeCp[12], pData->m_aCurrentTimeCp[13], pData->m_aCurrentTimeCp[14], + pData->m_aCurrentTimeCp[15], pData->m_aCurrentTimeCp[16], pData->m_aCurrentTimeCp[17], + pData->m_aCurrentTimeCp[18], pData->m_aCurrentTimeCp[19], pData->m_aCurrentTimeCp[20], + pData->m_aCurrentTimeCp[21], pData->m_aCurrentTimeCp[22], pData->m_aCurrentTimeCp[23], + pData->m_aCurrentTimeCp[24], pSqlServer->False()); if(pSqlServer->PrepareStatement(aBuf, pError, ErrorSize)) { return true; diff --git a/src/game/server/scoreworker.h b/src/game/server/scoreworker.h index 98256da16..eea60dcac 100644 --- a/src/game/server/scoreworker.h +++ b/src/game/server/scoreworker.h @@ -46,7 +46,7 @@ struct CScorePlayerResult : ISqlResult struct { float m_Time; - float m_CpTime[NUM_CHECKPOINTS]; + float m_aTimeCp[NUM_CHECKPOINTS]; int m_Score; int m_HasFinishScore; int m_Birthday; // 0 indicates no birthday @@ -141,7 +141,7 @@ struct CSqlScoreData : ISqlData int m_ClientID; float m_Time; char m_aTimestamp[TIMESTAMP_STR_LENGTH]; - float m_aCpCurrent[NUM_CHECKPOINTS]; + float m_aCurrentTimeCp[NUM_CHECKPOINTS]; int m_Num; bool m_Search; char m_aRequestingPlayer[MAX_NAME_LENGTH]; @@ -233,21 +233,21 @@ public: { m_BestTime = 0; m_CurrentTime = 0; - for(float &BestCpTime : m_aBestCpTime) - BestCpTime = 0; + for(float &BestTimeCp : m_aBestTimeCp) + BestTimeCp = 0; } - void Set(float Time, float CpTime[NUM_CHECKPOINTS]) + void Set(float Time, float aTimeCp[NUM_CHECKPOINTS]) { m_BestTime = Time; m_CurrentTime = Time; for(int i = 0; i < NUM_CHECKPOINTS; i++) - m_aBestCpTime[i] = CpTime[i]; + m_aBestTimeCp[i] = aTimeCp[i]; } float m_BestTime; float m_CurrentTime; - float m_aBestCpTime[NUM_CHECKPOINTS]; + float m_aBestTimeCp[NUM_CHECKPOINTS]; }; struct CTeamrank diff --git a/src/game/server/teams.cpp b/src/game/server/teams.cpp index 892efc332..d15aac639 100644 --- a/src/game/server/teams.cpp +++ b/src/game/server/teams.cpp @@ -615,24 +615,24 @@ void CGameTeams::SetStartTime(CPlayer *Player, int StartTime) pChar->m_StartTime = StartTime; } -void CGameTeams::SetCpActive(CPlayer *Player, int CpActive) +void CGameTeams::SetLastTimeCp(CPlayer *Player, int LastTimeCp) { if(!Player) return; CCharacter *pChar = Player->GetCharacter(); if(pChar) - pChar->m_CpActive = CpActive; + pChar->m_LastTimeCp = LastTimeCp; } -float *CGameTeams::GetCpCurrent(CPlayer *Player) +float *CGameTeams::GetCurrentTimeCp(CPlayer *Player) { if(!Player) return NULL; CCharacter *pChar = Player->GetCharacter(); if(pChar) - return pChar->m_CpCurrent; + return pChar->m_aCurrentTimeCp; return NULL; } @@ -667,7 +667,7 @@ void CGameTeams::OnFinish(CPlayer *Player, float Time, const char *pTimestamp) CPlayerData *pData = GameServer()->Score()->PlayerData(ClientID); char aBuf[128]; - SetCpActive(Player, -2); + SetLastTimeCp(Player, -1); // Note that the "finished in" message is parsed by the client str_format(aBuf, sizeof(aBuf), "%s finished in: %d minute(s) %5.2f second(s)", @@ -727,14 +727,14 @@ void CGameTeams::OnFinish(CPlayer *Player, float Time, const char *pTimestamp) if(!pData->m_BestTime || Time < pData->m_BestTime) { // update the score - pData->Set(Time, GetCpCurrent(Player)); + pData->Set(Time, GetCurrentTimeCp(Player)); CallSaveScore = true; } if(CallSaveScore) if(g_Config.m_SvNamelessScore || !str_startswith(Server()->ClientName(ClientID), "nameless tee")) GameServer()->Score()->SaveScore(ClientID, Time, pTimestamp, - GetCpCurrent(Player), Player->m_NotEligibleForFinish); + GetCurrentTimeCp(Player), Player->m_NotEligibleForFinish); bool NeedToSendNewRecord = false; // update server best time diff --git a/src/game/server/teams.h b/src/game/server/teams.h index 9ff2c4471..d8288d757 100644 --- a/src/game/server/teams.h +++ b/src/game/server/teams.h @@ -114,10 +114,10 @@ public: int GetDDRaceState(CPlayer *Player); int GetStartTime(CPlayer *Player); - float *GetCpCurrent(CPlayer *Player); + float *GetCurrentTimeCp(CPlayer *Player); void SetDDRaceState(CPlayer *Player, int DDRaceState); void SetStartTime(CPlayer *Player, int StartTime); - void SetCpActive(CPlayer *Player, int CpActive); + void SetLastTimeCp(CPlayer *Player, int LastTimeCp); void KillSavedTeam(int ClientID, int Team); void ResetSavedTeam(int ClientID, int Team); void RequestTeamSwap(CPlayer *pPlayer, CPlayer *pTargetPlayer, int Team); diff --git a/src/test/score.cpp b/src/test/score.cpp index 5255a745b..f069d8731 100644 --- a/src/test/score.cpp +++ b/src/test/score.cpp @@ -101,7 +101,7 @@ struct Score : public testing::TestWithParam ScoreData.m_Time = Time; str_copy(ScoreData.m_aTimestamp, "2021-11-24 19:24:08", sizeof(ScoreData.m_aTimestamp)); for(int i = 0; i < NUM_CHECKPOINTS; i++) - ScoreData.m_aCpCurrent[i] = WithTimeCheckPoints ? i : 0; + ScoreData.m_aCurrentTimeCp[i] = WithTimeCheckPoints ? i : 0; str_copy(ScoreData.m_aRequestingPlayer, "deen", sizeof(ScoreData.m_aRequestingPlayer)); ASSERT_FALSE(CScoreWorker::SaveScore(m_pConn, &ScoreData, false, m_aError, sizeof(m_aError))) << m_aError; } @@ -185,7 +185,7 @@ TEST_P(SingleScore, LoadPlayerData) ASSERT_EQ(m_pPlayerResult->m_Data.m_Info.m_Time, 0.0); for(int i = 0; i < NUM_CHECKPOINTS; i++) { - ASSERT_EQ(m_pPlayerResult->m_Data.m_Info.m_CpTime[i], 0); + ASSERT_EQ(m_pPlayerResult->m_Data.m_Info.m_aTimeCp[i], 0); } str_copy(m_PlayerRequest.m_aRequestingPlayer, "nameless tee", sizeof(m_PlayerRequest.m_aRequestingPlayer)); @@ -196,7 +196,7 @@ TEST_P(SingleScore, LoadPlayerData) ASSERT_EQ(m_pPlayerResult->m_Data.m_Info.m_Time, 100.0); for(int i = 0; i < NUM_CHECKPOINTS; i++) { - ASSERT_EQ(m_pPlayerResult->m_Data.m_Info.m_CpTime[i], i); + ASSERT_EQ(m_pPlayerResult->m_Data.m_Info.m_aTimeCp[i], i); } str_copy(m_PlayerRequest.m_aRequestingPlayer, "finishless", sizeof(m_PlayerRequest.m_aRequestingPlayer)); @@ -207,7 +207,7 @@ TEST_P(SingleScore, LoadPlayerData) ASSERT_EQ(m_pPlayerResult->m_Data.m_Info.m_Time, 0.0); for(int i = 0; i < NUM_CHECKPOINTS; i++) { - ASSERT_EQ(m_pPlayerResult->m_Data.m_Info.m_CpTime[i], i); + ASSERT_EQ(m_pPlayerResult->m_Data.m_Info.m_aTimeCp[i], i); } }