mirror of
https://github.com/ddnet/ddnet.git
synced 2024-11-10 10:08:18 +00:00
Merge #6227
6227: Fix more issues with the `restart` command r=def- a=Robyt3 Closes #6168. Not resetting the team when restarting requires too much effort for a feature that would only be active with the non-default `sv_rejoin_team_0 0` setting. If the `restart` command is used for testing a map or for tournaments, it would be easy enough as a workaround to create a bind to join a specific team after restarting, so I don't think this is necessary. ## Checklist - [X] Tested the change ingame - [ ] Provided screenshots if it is a visual change - [ ] Tested in combination with possibly related configuration options - [ ] Written a unit test (especially base/) or added coverage to integration test - [ ] Considered possible null pointers and out of bounds array indexing - [ ] Changed no physics that affect existing maps - [ ] Tested the change with [ASan+UBSan or valgrind's memcheck](https://github.com/ddnet/ddnet/#using-addresssanitizer--undefinedbehavioursanitizer-or-valgrinds-memcheck) (optional) Co-authored-by: Robert Müller <robytemueller@gmail.com>
This commit is contained in:
commit
4ca0506690
|
@ -810,18 +810,10 @@ void CGameClient::OnMessage(int MsgId, CUnpacker *pUnpacker, int Conn, bool Dumm
|
|||
|
||||
for(i = 0; i < MAX_CLIENTS; i++)
|
||||
{
|
||||
int Team = pUnpacker->GetInt();
|
||||
bool WentWrong = false;
|
||||
|
||||
if(pUnpacker->Error())
|
||||
WentWrong = true;
|
||||
|
||||
if(!WentWrong && Team >= TEAM_FLOCK && Team <= TEAM_SUPER)
|
||||
const int Team = pUnpacker->GetInt();
|
||||
if(!pUnpacker->Error() && Team >= TEAM_FLOCK && Team <= TEAM_SUPER)
|
||||
m_Teams.Team(i, Team);
|
||||
else
|
||||
WentWrong = true;
|
||||
|
||||
if(WentWrong)
|
||||
{
|
||||
m_Teams.Team(i, 0);
|
||||
break;
|
||||
|
@ -883,6 +875,17 @@ void CGameClient::OnStartGame()
|
|||
m_Statboard.OnReset();
|
||||
}
|
||||
|
||||
void CGameClient::OnStartRound()
|
||||
{
|
||||
// In GamePaused or GameOver state RoundStartTick is updated on each tick
|
||||
// hence no need to reset stats until player leaves GameOver
|
||||
// and it would be a mistake to reset stats after or during the pause
|
||||
m_Statboard.OnReset();
|
||||
|
||||
// Restart automatic race demo recording
|
||||
m_RaceDemo.OnReset();
|
||||
}
|
||||
|
||||
void CGameClient::OnFlagGrab(int TeamID)
|
||||
{
|
||||
if(TeamID == TEAM_RED)
|
||||
|
@ -1404,14 +1407,10 @@ void CGameClient::OnNewSnapshot()
|
|||
OnGameOver();
|
||||
else if(s_GameOver && !CurrentTickGameOver)
|
||||
OnStartGame();
|
||||
// Reset statboard when new round is started (RoundStartTick changed)
|
||||
// Handle case that a new round is started (RoundStartTick changed)
|
||||
// New round is usually started after `restart` on server
|
||||
if(m_Snap.m_pGameInfoObj->m_RoundStartTick != m_LastRoundStartTick
|
||||
// In GamePaused or GameOver state RoundStartTick is updated on each tick
|
||||
// hence no need to reset stats until player leaves GameOver
|
||||
// and it would be a mistake to reset stats after or during the pause
|
||||
&& !(CurrentTickGameOver || m_Snap.m_pGameInfoObj->m_GameStateFlags & GAMESTATEFLAG_PAUSED || s_GamePaused))
|
||||
m_Statboard.OnReset();
|
||||
if(m_Snap.m_pGameInfoObj->m_RoundStartTick != m_LastRoundStartTick && !(CurrentTickGameOver || m_Snap.m_pGameInfoObj->m_GameStateFlags & GAMESTATEFLAG_PAUSED || s_GamePaused))
|
||||
OnStartRound();
|
||||
m_LastRoundStartTick = m_Snap.m_pGameInfoObj->m_RoundStartTick;
|
||||
s_GameOver = CurrentTickGameOver;
|
||||
s_GamePaused = (bool)(m_Snap.m_pGameInfoObj->m_GameStateFlags & GAMESTATEFLAG_PAUSED);
|
||||
|
|
|
@ -470,6 +470,7 @@ public:
|
|||
void OnRconLine(const char *pLine) override;
|
||||
virtual void OnGameOver();
|
||||
virtual void OnStartGame();
|
||||
virtual void OnStartRound();
|
||||
virtual void OnFlagGrab(int TeamID);
|
||||
|
||||
void OnWindowResize();
|
||||
|
|
|
@ -24,6 +24,7 @@ void CGameTeams::Reset()
|
|||
m_aTeeStarted[i] = false;
|
||||
m_aTeeFinished[i] = false;
|
||||
m_aLastChat[i] = 0;
|
||||
SendTeamsState(i);
|
||||
}
|
||||
|
||||
for(int i = 0; i < NUM_TEAMS; ++i)
|
||||
|
|
Loading…
Reference in a new issue