New try at loading in team only

This commit is contained in:
def 2017-05-17 22:30:13 +02:00
parent 569f17e3f3
commit 7e7d56048b
2 changed files with 36 additions and 24 deletions

View file

@ -264,27 +264,34 @@ int CSaveTeam::load(int Team)
if(Team <= 0 || Team >= MAX_CLIENTS)
return 1;
CGameTeams* Teams = &(((CGameControllerDDRace*)m_pController)->m_Teams);
CGameTeams* pTeams = &(((CGameControllerDDRace*)m_pController)->m_Teams);
Teams->ChangeTeamState(Team, m_TeamState);
Teams->SetTeamLock(Team, m_TeamLocked);
if(pTeams->Count(Team) > m_MembersCount)
return 2;
pTeams->ChangeTeamState(Team, m_TeamState);
pTeams->SetTeamLock(Team, m_TeamLocked);
CCharacter *pChr;
for (int i = 0; i<m_MembersCount; i++)
for (int i = 0; i < m_MembersCount; i++)
{
int ID = MatchPlayer(SavedTees[i].GetName());
if(ID == -1) // first check if team can be loaded / do not load half teams
{
return i+10; // +10 to let space for other return-values
return i+10; // +10 to leave space for other return-values
}
else if (m_pController->GameServer()->m_apPlayers[ID] && m_pController->GameServer()->m_apPlayers[ID]->GetCharacter() && m_pController->GameServer()->m_apPlayers[ID]->GetCharacter()->m_DDRaceState)
if(m_pController->GameServer()->m_apPlayers[ID] && m_pController->GameServer()->m_apPlayers[ID]->GetCharacter() && m_pController->GameServer()->m_apPlayers[ID]->GetCharacter()->m_DDRaceState)
{
return i+100; // +100 to let space for other return-values
return i+100; // +100 to leave space for other return-values
}
if(Team != pTeams->m_Core.Team(ID))
{
return i+200; // +100 to leave space for other return-values
}
}
for (int i = 0; i<m_MembersCount; i++)
for (int i = 0; i < m_MembersCount; i++)
{
pChr = MatchCharacter(SavedTees[i].GetName(), i);
if(pChr)

View file

@ -1536,45 +1536,50 @@ bool CSqlScore::LoadTeamThread(CSqlServer* pSqlServer, const CSqlData *pGameData
for (int i = 0; i < SavedTeam.GetMembersCount(); i++)
{
if(str_comp(SavedTeam.SavedTees[i].GetName(), pData->Server()->ClientName(pData->m_ClientID)) == 0)
{ Found = true; break; }
{
Found = true;
break;
}
}
if (!Found)
if(!Found)
pData->GameServer()->SendChatTarget(pData->m_ClientID, "You don't belong to this team");
else
{
int n;
for(n = 1; n<64; n++)
{
if(((CGameControllerDDRace*)(pData->GameServer()->m_pController))->m_Teams.Count(n) == 0)
break;
}
int Team = ((CGameControllerDDRace*)(pData->GameServer()->m_pController))->m_Teams.m_Core.Team(pData->m_ClientID);
if(((CGameControllerDDRace*)(pData->GameServer()->m_pController))->m_Teams.Count(n) > 0)
{
n = ((CGameControllerDDRace*)(pData->GameServer()->m_pController))->m_Teams.m_Core.Team(pData->m_ClientID); // if all Teams are full your the only one in your team
}
Num = SavedTeam.load(n);
Num = SavedTeam.load(Team);
if(Num == 1)
{
pData->GameServer()->SendChatTarget(pData->m_ClientID, "You have to be in a team (from 1-63)");
}
if(Num == 2)
{
char aBuf[256];
str_format(aBuf, sizeof(aBuf), "Too many players in this team, should be %d", SavedTeam.GetMembersCount());
pData->GameServer()->SendChatTarget(pData->m_ClientID, aBuf);
}
else if(Num >= 10 && Num < 100)
{
char aBuf[256];
str_format(aBuf, sizeof(aBuf), "Unable to find player: '%s'", SavedTeam.SavedTees[Num-10].GetName());
pData->GameServer()->SendChatTarget(pData->m_ClientID, aBuf);
}
else if(Num >= 100)
else if(Num >= 100 && Num < 200)
{
char aBuf[256];
str_format(aBuf, sizeof(aBuf), "%s is racing right now, Team can't be loaded if a Tee is racing already", SavedTeam.SavedTees[Num-100].GetName());
pData->GameServer()->SendChatTarget(pData->m_ClientID, aBuf);
}
else if(Num >= 200)
{
char aBuf[256];
str_format(aBuf, sizeof(aBuf), "Everyone has to be in a team, %s is in team 0 or the wrong team", SavedTeam.SavedTees[Num-200].GetName());
pData->GameServer()->SendChatTarget(pData->m_ClientID, aBuf);
}
else
{
pData->GameServer()->SendChatTeam(n, "Loading successfully done");
pData->GameServer()->SendChatTeam(Team, "Loading successfully done");
char aBuf[512];
str_format(aBuf, sizeof(aBuf), "DELETE from %s_saves where Code='%s' and Map='%s';", pSqlServer->GetPrefix(), pData->m_Code.ClrStr(), pData->m_Map.ClrStr());
pSqlServer->executeSql(aBuf);