Fix range of team related bugs by actually removing people from team when they spectate

This commit is contained in:
def 2014-01-11 15:19:34 +01:00
parent cedd472c04
commit 6126ad50c4
4 changed files with 34 additions and 21 deletions

View file

@ -811,15 +811,6 @@ void CCharacter::Die(int Killer, int Weapon)
Msg.m_ModeSpecial = ModeSpecial;
Server()->SendPackMsg(&Msg, MSGFLAG_VITAL, -1);
// reset switches if we are the last player in team to prevent door opening cheat
if (((Team() == TEAM_FLOCK && g_Config.m_SvTeam == 3) || (Team() > TEAM_FLOCK && Team() < TEAM_SUPER && (Teams()->Count(Team()) < 2 || Teams()->TeamLocked(Team())))) && GameServer()->Collision()->m_NumSwitchers > 0) {
for (int i = 0; i < GameServer()->Collision()->m_NumSwitchers+1; ++i) {
GameServer()->Collision()->m_pSwitchers[i].m_Status[Team()] = true;
GameServer()->Collision()->m_pSwitchers[i].m_EndTick[Team()] = 0;
GameServer()->Collision()->m_pSwitchers[i].m_Type[Team()] = TILE_SWITCHOPEN;
}
}
// a nice sound
GameServer()->CreateSound(m_Pos, SOUND_PLAYER_DIE, Teams()->TeamMask(Team(), -1, m_pPlayer->GetCID()));

View file

@ -419,6 +419,7 @@ void CPlayer::SetTeam(int Team, bool DoChatMsg)
if(Team == TEAM_SPECTATORS)
{
CGameControllerDDRace* Controller = (CGameControllerDDRace*)GameServer()->m_pController;
Controller->m_Teams.ForceLeaveTeam(m_ClientID);
Controller->m_Teams.m_Core.Team(m_ClientID, 0);
}

View file

@ -166,8 +166,39 @@ bool CGameTeams::SetCharacterTeam(int ClientID, int Team)
}
void CGameTeams::SetForceCharacterTeam(int ClientID, int Team)
{
ForceLeaveTeam(ClientID);
m_Core.Team(ClientID, Team);
if (m_Core.Team(ClientID) != TEAM_SUPER)
m_MembersCount[m_Core.Team(ClientID)]++;
if (Team != TEAM_SUPER && m_TeamState[Team] == TEAMSTATE_EMPTY)
{
ChangeTeamState(Team, TEAMSTATE_OPEN);
if (GameServer()->Collision()->m_NumSwitchers > 0) {
for (int i = 0; i < GameServer()->Collision()->m_NumSwitchers+1; ++i)
{
GameServer()->Collision()->m_pSwitchers[i].m_Status[Team] = true;
GameServer()->Collision()->m_pSwitchers[i].m_EndTick[Team] = 0;
GameServer()->Collision()->m_pSwitchers[i].m_Type[Team] = TILE_SWITCHOPEN;
}
}
}
//for (int LoopClientID = 0; LoopClientID < MAX_CLIENTS; ++LoopClientID)
//{
// if (GetPlayer(LoopClientID)
// && GetPlayer(LoopClientID)->m_IsUsingDDRaceClient)
// SendTeamsState(LoopClientID);
//}
}
void CGameTeams::ForceLeaveTeam(int ClientID)
{
m_TeeFinished[ClientID] = false;
if (m_Core.Team(ClientID) != TEAM_FLOCK
&& m_Core.Team(ClientID) != TEAM_SUPER
&& m_TeamState[m_Core.Team(ClientID)] != TEAMSTATE_EMPTY)
@ -187,20 +218,9 @@ void CGameTeams::SetForceCharacterTeam(int ClientID, int Team)
SetTeamLock(m_Core.Team(ClientID), false);
}
}
if (Count(m_Core.Team(ClientID)) > 0)
m_MembersCount[m_Core.Team(ClientID)]--;
m_Core.Team(ClientID, Team);
if (m_Core.Team(ClientID) != TEAM_SUPER)
m_MembersCount[m_Core.Team(ClientID)]++;
if (Team != TEAM_SUPER && m_TeamState[Team] == TEAMSTATE_EMPTY)
ChangeTeamState(Team, TEAMSTATE_OPEN);
//for (int LoopClientID = 0; LoopClientID < MAX_CLIENTS; ++LoopClientID)
//{
// if (GetPlayer(LoopClientID)
// && GetPlayer(LoopClientID)->m_IsUsingDDRaceClient)
// SendTeamsState(LoopClientID);
//}
}
int CGameTeams::Count(int Team) const

View file

@ -61,6 +61,7 @@ public:
//need to be very carefull using this method
void SetForceCharacterTeam(int id, int Team);
void ForceLeaveTeam(int id);
void Reset();