mirror of
https://github.com/ddnet/ddnet.git
synced 2024-11-19 06:28:19 +00:00
Cleanup if nesting
This commit is contained in:
parent
ce5a7ea626
commit
905204781b
|
@ -27,31 +27,32 @@ void CGameTeams::OnCharacterStart(int ClientID)
|
|||
{
|
||||
int Tick = Server()->Tick();
|
||||
CCharacter* pStartingChar = Character(ClientID);
|
||||
if (!pStartingChar)
|
||||
if(!pStartingChar)
|
||||
return;
|
||||
if (m_Core.Team(ClientID) != TEAM_FLOCK && pStartingChar->m_DDRaceState == DDRACE_FINISHED)
|
||||
if(m_Core.Team(ClientID) != TEAM_FLOCK && pStartingChar->m_DDRaceState == DDRACE_FINISHED)
|
||||
return;
|
||||
if (m_Core.Team(ClientID) == TEAM_FLOCK
|
||||
if(m_Core.Team(ClientID) == TEAM_FLOCK
|
||||
|| m_Core.Team(ClientID) == TEAM_SUPER)
|
||||
{
|
||||
pStartingChar->m_DDRaceState = DDRACE_STARTED;
|
||||
pStartingChar->m_StartTime = Tick;
|
||||
return;
|
||||
}
|
||||
else
|
||||
{
|
||||
bool Waiting = false;
|
||||
for (int i = 0; i < MAX_CLIENTS; ++i)
|
||||
{
|
||||
if (m_Core.Team(ClientID) == m_Core.Team(i))
|
||||
for(int i = 0; i < MAX_CLIENTS; ++i)
|
||||
{
|
||||
if(m_Core.Team(ClientID) != m_Core.Team(i))
|
||||
continue;
|
||||
CPlayer* pPlayer = GetPlayer(i);
|
||||
if (pPlayer && pPlayer->IsPlaying()
|
||||
&& GetDDRaceState(pPlayer) == DDRACE_FINISHED)
|
||||
{
|
||||
if(!pPlayer || !pPlayer->IsPlaying())
|
||||
continue;
|
||||
if(GetDDRaceState(pPlayer) != DDRACE_FINISHED)
|
||||
continue;
|
||||
|
||||
Waiting = true;
|
||||
pStartingChar->m_DDRaceState = DDRACE_NONE;
|
||||
|
||||
if (m_LastChat[ClientID] + Server()->TickSpeed()
|
||||
if(m_LastChat[ClientID] + Server()->TickSpeed()
|
||||
+ g_Config.m_SvChatDelay < Tick)
|
||||
{
|
||||
char aBuf[128];
|
||||
|
@ -63,7 +64,7 @@ void CGameTeams::OnCharacterStart(int ClientID)
|
|||
GameServer()->SendChatTarget(ClientID, aBuf);
|
||||
m_LastChat[ClientID] = Tick;
|
||||
}
|
||||
if (m_LastChat[i] + Server()->TickSpeed()
|
||||
if(m_LastChat[i] + Server()->TickSpeed()
|
||||
+ g_Config.m_SvChatDelay < Tick)
|
||||
{
|
||||
char aBuf[128];
|
||||
|
@ -76,10 +77,8 @@ void CGameTeams::OnCharacterStart(int ClientID)
|
|||
m_LastChat[i] = Tick;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (m_TeamState[m_Core.Team(ClientID)] < TEAMSTATE_STARTED && !Waiting)
|
||||
if(m_TeamState[m_Core.Team(ClientID)] < TEAMSTATE_STARTED && !Waiting)
|
||||
{
|
||||
ChangeTeamState(m_Core.Team(ClientID), TEAMSTATE_STARTED);
|
||||
|
||||
|
@ -93,18 +92,18 @@ void CGameTeams::OnCharacterStart(int ClientID)
|
|||
|
||||
bool First = true;
|
||||
|
||||
for (int i = 0; i < MAX_CLIENTS; ++i)
|
||||
for(int i = 0; i < MAX_CLIENTS; ++i)
|
||||
{
|
||||
if (m_Core.Team(ClientID) == m_Core.Team(i))
|
||||
if(m_Core.Team(ClientID) == m_Core.Team(i))
|
||||
{
|
||||
CPlayer* pPlayer = GetPlayer(i);
|
||||
// TODO: THE PROBLEM IS THAT THERE IS NO CHARACTER SO START TIME CAN'T BE SET!
|
||||
if (pPlayer && (pPlayer->IsPlaying() || TeamLocked(m_Core.Team(ClientID))))
|
||||
if(pPlayer && (pPlayer->IsPlaying() || TeamLocked(m_Core.Team(ClientID))))
|
||||
{
|
||||
SetDDRaceState(pPlayer, DDRACE_STARTED);
|
||||
SetStartTime(pPlayer, Tick);
|
||||
|
||||
if (First)
|
||||
if(First)
|
||||
First = false;
|
||||
else
|
||||
str_append(aBuf, ", ", sizeof(aBuf));
|
||||
|
@ -114,19 +113,18 @@ void CGameTeams::OnCharacterStart(int ClientID)
|
|||
}
|
||||
}
|
||||
|
||||
if (g_Config.m_SvTeam < 3 && g_Config.m_SvTeamMaxSize != 2 && g_Config.m_SvPauseable)
|
||||
if(g_Config.m_SvTeam < 3 && g_Config.m_SvTeamMaxSize != 2 && g_Config.m_SvPauseable)
|
||||
{
|
||||
for (int i = 0; i < MAX_CLIENTS; ++i)
|
||||
for(int i = 0; i < MAX_CLIENTS; ++i)
|
||||
{
|
||||
CPlayer* pPlayer = GetPlayer(i);
|
||||
if (m_Core.Team(ClientID) == m_Core.Team(i) && pPlayer && (pPlayer->IsPlaying() || TeamLocked(m_Core.Team(ClientID))))
|
||||
if(m_Core.Team(ClientID) == m_Core.Team(i) && pPlayer && (pPlayer->IsPlaying() || TeamLocked(m_Core.Team(ClientID))))
|
||||
{
|
||||
GameServer()->SendChatTarget(i, aBuf);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void CGameTeams::OnCharacterFinish(int ClientID)
|
||||
|
|
Loading…
Reference in a new issue