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

Method SendFinish

src/game/server/gamecontext.cpp:4810–4852  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

4808}
4809
4810void CGameContext::SendFinish(int ClientId, float Time, std::optional<float> PreviousBestTime)
4811{
4812 int ClientVersion = m_apPlayers[ClientId]->GetClientVersion();
4813
4814 if(!Server()->IsSixup(ClientId))
4815 {
4816 CNetMsg_Sv_DDRaceTime Msg;
4817 CNetMsg_Sv_DDRaceTimeLegacy MsgLegacy;
4818 MsgLegacy.m_Time = Msg.m_Time = (int)(Time * 100.0f);
4819 MsgLegacy.m_Check = Msg.m_Check = 0;
4820 MsgLegacy.m_Finish = Msg.m_Finish = 1;
4821
4822 if(PreviousBestTime.has_value())
4823 {
4824 float Diff100 = (Time - PreviousBestTime.value()) * 100;
4825 MsgLegacy.m_Check = Msg.m_Check = (int)Diff100;
4826 }
4827 if(VERSION_DDRACE <= ClientVersion)
4828 {
4829 if(ClientVersion < VERSION_DDNET_MSG_LEGACY)
4830 {
4831 Server()->SendPackMsg(&Msg, MSGFLAG_VITAL, ClientId);
4832 }
4833 else
4834 {
4835 Server()->SendPackMsg(&MsgLegacy, MSGFLAG_VITAL, ClientId);
4836 }
4837 }
4838 }
4839
4840 CNetMsg_Sv_RaceFinish RaceFinishMsg;
4841 RaceFinishMsg.m_ClientId = ClientId;
4842 RaceFinishMsg.m_Time = Time * 1000;
4843 RaceFinishMsg.m_Diff = 0;
4844 if(PreviousBestTime.has_value())
4845 {
4846 float Diff = absolute(Time - PreviousBestTime.value());
4847 RaceFinishMsg.m_Diff = Diff * 1000 * (Time < PreviousBestTime.value() ? -1 : 1);
4848 }
4849 RaceFinishMsg.m_RecordPersonal = (!PreviousBestTime.has_value() || Time < PreviousBestTime.value());
4850 RaceFinishMsg.m_RecordServer = Time < m_pController->m_CurrentRecord;
4851 Server()->SendPackMsg(&RaceFinishMsg, MSGFLAG_VITAL | MSGFLAG_NORECORD, g_Config.m_SvHideScore ? ClientId : -1);
4852}
4853
4854void CGameContext::SendSaveCode(int Team, int TeamSize, int State, const char *pError, const char *pSaveRequester, const char *pServerName, const char *pGeneratedCode, const char *pCode)
4855{

Callers 1

OnFinishMethod · 0.80

Calls 5

absoluteFunction · 0.85
ServerClass · 0.50
GetClientVersionMethod · 0.45
IsSixupMethod · 0.45
SendPackMsgMethod · 0.45

Tested by

no test coverage detected