mirror of
https://github.com/ddnet/ddnet.git
synced 2024-11-19 06:28:19 +00:00
Fix potential inconsistencies in rank/teamrank
This commit is contained in:
parent
a689533a9d
commit
f5e8b9d822
|
@ -136,7 +136,13 @@ void CGameTeams::OnCharacterFinish(int ClientID)
|
||||||
{
|
{
|
||||||
CPlayer* pPlayer = GetPlayer(ClientID);
|
CPlayer* pPlayer = GetPlayer(ClientID);
|
||||||
if (pPlayer && pPlayer->IsPlaying())
|
if (pPlayer && pPlayer->IsPlaying())
|
||||||
OnFinish(pPlayer);
|
{
|
||||||
|
float Time = (float)(Server()->Tick() - GetStartTime(pPlayer))
|
||||||
|
/ ((float)Server()->TickSpeed());
|
||||||
|
if (Time < 0.000001f)
|
||||||
|
return;
|
||||||
|
OnFinish(pPlayer, Time);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -160,7 +166,6 @@ void CGameTeams::CheckTeamFinished(int Team)
|
||||||
CPlayer* pPlayer = GetPlayer(i);
|
CPlayer* pPlayer = GetPlayer(i);
|
||||||
if (pPlayer && pPlayer->IsPlaying())
|
if (pPlayer && pPlayer->IsPlaying())
|
||||||
{
|
{
|
||||||
OnFinish(pPlayer);
|
|
||||||
m_TeeFinished[i] = false;
|
m_TeeFinished[i] = false;
|
||||||
|
|
||||||
TeamPlayers[PlayersCount++] = pPlayer;
|
TeamPlayers[PlayersCount++] = pPlayer;
|
||||||
|
@ -170,9 +175,16 @@ void CGameTeams::CheckTeamFinished(int Team)
|
||||||
|
|
||||||
if (PlayersCount > 0)
|
if (PlayersCount > 0)
|
||||||
{
|
{
|
||||||
|
float Time = (float)(Server()->Tick() - GetStartTime(TeamPlayers[0]))
|
||||||
|
/ ((float)Server()->TickSpeed());
|
||||||
|
if (Time < 0.000001f)
|
||||||
|
return;
|
||||||
|
|
||||||
|
for (auto pPlayer : TeamPlayers)
|
||||||
|
OnFinish(pPlayer, Time);
|
||||||
ChangeTeamState(Team, TEAMSTATE_FINISHED); //TODO: Make it better
|
ChangeTeamState(Team, TEAMSTATE_FINISHED); //TODO: Make it better
|
||||||
//ChangeTeamState(Team, TEAMSTATE_OPEN);
|
//ChangeTeamState(Team, TEAMSTATE_OPEN);
|
||||||
OnTeamFinish(TeamPlayers, PlayersCount);
|
OnTeamFinish(TeamPlayers, PlayersCount, Time);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -443,13 +455,8 @@ float *CGameTeams::GetCpCurrent(CPlayer* Player)
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
void CGameTeams::OnTeamFinish(CPlayer** Players, unsigned int Size)
|
void CGameTeams::OnTeamFinish(CPlayer** Players, unsigned int Size, float Time)
|
||||||
{
|
{
|
||||||
float Time = (float)(Server()->Tick() - GetStartTime(Players[0]))
|
|
||||||
/ ((float)Server()->TickSpeed());
|
|
||||||
if (Time < 0.000001f)
|
|
||||||
return;
|
|
||||||
|
|
||||||
bool CallSaveScore = false;
|
bool CallSaveScore = false;
|
||||||
|
|
||||||
#if defined(CONF_SQL)
|
#if defined(CONF_SQL)
|
||||||
|
@ -476,15 +483,11 @@ void CGameTeams::OnTeamFinish(CPlayer** Players, unsigned int Size)
|
||||||
GameServer()->Score()->SaveTeamScore(PlayerCIDs, Size, Time);
|
GameServer()->Score()->SaveTeamScore(PlayerCIDs, Size, Time);
|
||||||
}
|
}
|
||||||
|
|
||||||
void CGameTeams::OnFinish(CPlayer* Player)
|
void CGameTeams::OnFinish(CPlayer* Player, float Time)
|
||||||
{
|
{
|
||||||
if (!Player || !Player->IsPlaying())
|
if (!Player || !Player->IsPlaying())
|
||||||
return;
|
return;
|
||||||
//TODO:DDRace:btd: this ugly
|
//TODO:DDRace:btd: this ugly
|
||||||
float Time = (float)(Server()->Tick() - GetStartTime(Player))
|
|
||||||
/ ((float)Server()->TickSpeed());
|
|
||||||
if (Time < 0.000001f)
|
|
||||||
return;
|
|
||||||
CPlayerData *pData = GameServer()->Score()->PlayerData(Player->GetCID());
|
CPlayerData *pData = GameServer()->Score()->PlayerData(Player->GetCID());
|
||||||
char aBuf[128];
|
char aBuf[128];
|
||||||
SetCpActive(Player, -2);
|
SetCpActive(Player, -2);
|
||||||
|
|
|
@ -16,6 +16,11 @@ class CGameTeams
|
||||||
|
|
||||||
class CGameContext * m_pGameContext;
|
class CGameContext * m_pGameContext;
|
||||||
|
|
||||||
|
void CheckTeamFinished(int ClientID);
|
||||||
|
bool TeamFinished(int Team);
|
||||||
|
void OnTeamFinish(CPlayer** Players, unsigned int Size, float Time);
|
||||||
|
void OnFinish(CPlayer* Player, float Time);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
enum
|
enum
|
||||||
{
|
{
|
||||||
|
@ -50,14 +55,11 @@ public:
|
||||||
void OnCharacterSpawn(int ClientID);
|
void OnCharacterSpawn(int ClientID);
|
||||||
void OnCharacterDeath(int ClientID, int Weapon);
|
void OnCharacterDeath(int ClientID, int Weapon);
|
||||||
|
|
||||||
void CheckTeamFinished(int ClientID);
|
|
||||||
bool SetCharacterTeam(int ClientID, int Team);
|
bool SetCharacterTeam(int ClientID, int Team);
|
||||||
|
|
||||||
void ChangeTeamState(int Team, int State);
|
void ChangeTeamState(int Team, int State);
|
||||||
void onChangeTeamState(int Team, int State, int OldState);
|
void onChangeTeamState(int Team, int State, int OldState);
|
||||||
|
|
||||||
bool TeamFinished(int Team);
|
|
||||||
|
|
||||||
int64_t TeamMask(int Team, int ExceptID = -1, int Asker = -1);
|
int64_t TeamMask(int Team, int ExceptID = -1, int Asker = -1);
|
||||||
|
|
||||||
int Count(int Team) const;
|
int Count(int Team) const;
|
||||||
|
@ -81,8 +83,6 @@ public:
|
||||||
void SetDDRaceState(CPlayer* Player, int DDRaceState);
|
void SetDDRaceState(CPlayer* Player, int DDRaceState);
|
||||||
void SetStartTime(CPlayer* Player, int StartTime);
|
void SetStartTime(CPlayer* Player, int StartTime);
|
||||||
void SetCpActive(CPlayer* Player, int CpActive);
|
void SetCpActive(CPlayer* Player, int CpActive);
|
||||||
void OnTeamFinish(CPlayer** Players, unsigned int Size);
|
|
||||||
void OnFinish(CPlayer* Player);
|
|
||||||
void KillSavedTeam(int Team);
|
void KillSavedTeam(int Team);
|
||||||
|
|
||||||
bool TeeFinished(int ClientID)
|
bool TeeFinished(int ClientID)
|
||||||
|
|
Loading…
Reference in a new issue