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();
|
int Tick = Server()->Tick();
|
||||||
CCharacter* pStartingChar = Character(ClientID);
|
CCharacter* pStartingChar = Character(ClientID);
|
||||||
if (!pStartingChar)
|
if(!pStartingChar)
|
||||||
return;
|
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;
|
return;
|
||||||
if (m_Core.Team(ClientID) == TEAM_FLOCK
|
if(m_Core.Team(ClientID) == TEAM_FLOCK
|
||||||
|| m_Core.Team(ClientID) == TEAM_SUPER)
|
|| m_Core.Team(ClientID) == TEAM_SUPER)
|
||||||
{
|
{
|
||||||
pStartingChar->m_DDRaceState = DDRACE_STARTED;
|
pStartingChar->m_DDRaceState = DDRACE_STARTED;
|
||||||
pStartingChar->m_StartTime = Tick;
|
pStartingChar->m_StartTime = Tick;
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
else
|
|
||||||
{
|
|
||||||
bool Waiting = false;
|
bool Waiting = false;
|
||||||
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))
|
||||||
|
continue;
|
||||||
CPlayer* pPlayer = GetPlayer(i);
|
CPlayer* pPlayer = GetPlayer(i);
|
||||||
if (pPlayer && pPlayer->IsPlaying()
|
if(!pPlayer || !pPlayer->IsPlaying())
|
||||||
&& GetDDRaceState(pPlayer) == DDRACE_FINISHED)
|
continue;
|
||||||
{
|
if(GetDDRaceState(pPlayer) != DDRACE_FINISHED)
|
||||||
|
continue;
|
||||||
|
|
||||||
Waiting = true;
|
Waiting = true;
|
||||||
pStartingChar->m_DDRaceState = DDRACE_NONE;
|
pStartingChar->m_DDRaceState = DDRACE_NONE;
|
||||||
|
|
||||||
if (m_LastChat[ClientID] + Server()->TickSpeed()
|
if(m_LastChat[ClientID] + Server()->TickSpeed()
|
||||||
+ g_Config.m_SvChatDelay < Tick)
|
+ g_Config.m_SvChatDelay < Tick)
|
||||||
{
|
{
|
||||||
char aBuf[128];
|
char aBuf[128];
|
||||||
|
@ -63,7 +64,7 @@ void CGameTeams::OnCharacterStart(int ClientID)
|
||||||
GameServer()->SendChatTarget(ClientID, aBuf);
|
GameServer()->SendChatTarget(ClientID, aBuf);
|
||||||
m_LastChat[ClientID] = Tick;
|
m_LastChat[ClientID] = Tick;
|
||||||
}
|
}
|
||||||
if (m_LastChat[i] + Server()->TickSpeed()
|
if(m_LastChat[i] + Server()->TickSpeed()
|
||||||
+ g_Config.m_SvChatDelay < Tick)
|
+ g_Config.m_SvChatDelay < Tick)
|
||||||
{
|
{
|
||||||
char aBuf[128];
|
char aBuf[128];
|
||||||
|
@ -76,10 +77,8 @@ void CGameTeams::OnCharacterStart(int ClientID)
|
||||||
m_LastChat[i] = Tick;
|
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);
|
ChangeTeamState(m_Core.Team(ClientID), TEAMSTATE_STARTED);
|
||||||
|
|
||||||
|
@ -93,18 +92,18 @@ void CGameTeams::OnCharacterStart(int ClientID)
|
||||||
|
|
||||||
bool First = true;
|
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);
|
CPlayer* pPlayer = GetPlayer(i);
|
||||||
// TODO: THE PROBLEM IS THAT THERE IS NO CHARACTER SO START TIME CAN'T BE SET!
|
// 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);
|
SetDDRaceState(pPlayer, DDRACE_STARTED);
|
||||||
SetStartTime(pPlayer, Tick);
|
SetStartTime(pPlayer, Tick);
|
||||||
|
|
||||||
if (First)
|
if(First)
|
||||||
First = false;
|
First = false;
|
||||||
else
|
else
|
||||||
str_append(aBuf, ", ", sizeof(aBuf));
|
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);
|
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);
|
GameServer()->SendChatTarget(i, aBuf);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void CGameTeams::OnCharacterFinish(int ClientID)
|
void CGameTeams::OnCharacterFinish(int ClientID)
|
||||||
|
|
Loading…
Reference in a new issue