Esempio n. 1
0
void CTeamMgr::ResetAllTeams()
{
	CTeam* pTeam = m_lsTeams.GetFirst();

	while (pTeam)
	{
		pTeam->Reset();
		pTeam = pTeam->GetNext();
	}
}
Esempio n. 2
0
void CTeamMgr::SortTeams(int nSortKey, int nDir)
{
	// Sanity check...

	if (GetNumTeams() <= 1) return;


	// Remove each team from our list, and insert it, sorted, into a temp list...

	CTeamList lsTemp;

	CTeam* pCurTeam = GetFirstTeam();

	while (pCurTeam)
	{
		CTeam* pNextTeam = GetNextTeam(pCurTeam);

		m_lsTeams.Delete(pCurTeam);


		// Insert the team from our main list, sorted, into our temp list...

		CTeam* pTmpTeam = lsTemp.GetFirst();

		if (!pTmpTeam)
		{
			lsTemp.Insert(pCurTeam);
		}
		else
		{
			while (pTmpTeam)
			{
				if (nDir == TM_SORT_DESCENDING && IsGreater(pCurTeam, pTmpTeam, nSortKey))
				{
					lsTemp.InsertBefore(pTmpTeam, pCurTeam);
					pTmpTeam = NULL;
				}
				else if (nDir == TM_SORT_ASCENDING && IsLess(pCurTeam, pTmpTeam, nSortKey))
				{
					lsTemp.InsertBefore(pTmpTeam, pCurTeam);
					pTmpTeam = NULL;
				}
				else
				{
					pTmpTeam = pTmpTeam->GetNext();
					if (!pTmpTeam)
					{
						lsTemp.InsertLast(pCurTeam);
					}
				}
			}
		}

		pCurTeam = pNextTeam;
	}


	// Re-insert all items into our main list...

	CTeam* pTeam = lsTemp.GetFirst();

	while (pTeam)
	{
		CTeam* pNextTeam = pTeam->GetNext();
		m_lsTeams.InsertLast(pTeam);
		pTeam = pNextTeam;
	}
}