Remove tees that don't belong

This commit is contained in:
Learath 2017-04-12 10:33:02 +02:00
parent d29f2306ef
commit 47f405e160

View file

@ -1525,28 +1525,39 @@ bool CSqlScore::LoadTeamThread(CSqlServer* pSqlServer, const CSqlData *pGameData
}
int TeamCount = pController->m_Teams.Count(Team);
if(TeamCount != SavedTeam.GetMembersCount())
if(TeamCount < SavedTeam.GetMembersCount()) // Not enough
{
pData->GameServer()->SendChatTarget(pData->m_ClientID, "All saved tees must be present to load."); // Also list the missing tees I guess
pData->GameServer()->SendChatTarget(pData->m_ClientID, "All saved tees must be present to load"); // Also list the missing tees I guess
goto end;
}
int64_t TeamMask = pController->m_Teams.TeamMask(Team);
int Found = 0;
for(int i = 0; i < SavedTeam.GetMembersCount(); i++)
{
int CID = pData->Server()->GetClientID(SavedTeam.SavedTees[i]);
if(CID >= 0 && pController->m_Teams.m_Core.Team(CID) == Team)
Found++;
else
break;
int Found = 0;
bool Removed = false;
for (int i = 0; i < MAX_CLIENTS; ++i)
{
if(pController->m_Teams.m_Core.Team(i) == Team)
{
bool Allowed = false;
for(int j = 0; !Allowed && j < SavedTeam.GetMembersCount(); i++)
if(!str_comp(pData->Server()->ClientName(i), SavedTeam.SavedTees[j]))
Allowed = true;
if(!Allowed)
pController->m_Teams.SetForceCharacterTeam(i, TEAM_FLOCK);
Found += Allowed;
Removed |= !Allowed;
}
}
if(Found != SavedTeam.GetMembersCount())
{
pData->GameServer()->SendChatTarget(pData->m_ClientID, "All saved tees must be present to load."); // Also list the missing tees I guess
pData->GameServer()->SendChatTarget(pData->m_ClientID, "All saved tees must be present to load"); // Also list the missing tees I guess
goto end;
}
if(Removed)
pData->GameServer()->SendChatTarget(pData->m_ClientID, "Tees that don't belong to the save have been removed");
}
if(!SavedTeam.load(Team))
{