本文整理汇总了C++中C4Team::GetFirstUnjoinedPlayerID方法的典型用法代码示例。如果您正苦于以下问题:C++ C4Team::GetFirstUnjoinedPlayerID方法的具体用法?C++ C4Team::GetFirstUnjoinedPlayerID怎么用?C++ C4Team::GetFirstUnjoinedPlayerID使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类C4Team
的用法示例。
在下文中一共展示了C4Team::GetFirstUnjoinedPlayerID方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: GetRandomSmallestTeam
void C4TeamList::RecheckTeams()
{
// automatic team distributions only
if (!IsRandomTeam()) return;
// host decides random teams
if (!::Control.isCtrlHost())
{
// Still make sure that we have the right number of teams on the clients as well so that
// GetTeamCount() does not report inconsistent values.
EnsureTeamCount();
return;
}
// random teams in auto generate mode? Make sure there are exactly two teams
if (IsAutoGenerateTeams() && GetTeamCount() != 2)
{
ReassignAllTeams();
return;
}
// redistribute players of largest team that has relocatable players left towards smaller teams
for (;;)
{
C4Team *pLowestTeam = GetRandomSmallestTeam();
if (!pLowestTeam) break; // no teams: Nothing to re-distribute.
// get largest team that has relocateable players
C4Team *pLargestTeam = nullptr;
C4Team **ppCheck=ppList; int32_t iCnt=iTeamCount;
for (; iCnt--; ++ppCheck) if (!pLargestTeam || pLargestTeam->GetPlayerCount() > (*ppCheck)->GetPlayerCount())
if ((*ppCheck)->GetFirstUnjoinedPlayerID())
pLargestTeam = *ppCheck;
// no team can redistribute?
if (!pLargestTeam) break;
// redistribution won't help much?
if (pLargestTeam->GetPlayerCount() - pLowestTeam->GetPlayerCount() <= 1) break;
// okay; redistribute one player!
int32_t idRedistPlayer = pLargestTeam->GetFirstUnjoinedPlayerID();
C4PlayerInfo *pInfo = Game.PlayerInfos.GetPlayerInfoByID(idRedistPlayer);
assert(pInfo);
if (!pInfo) break; // umn...serious problems
pLargestTeam->RemovePlayerByID(idRedistPlayer);
pLowestTeam->AddPlayer(*pInfo, true);
C4ClientPlayerInfos *pClrInfo = Game.PlayerInfos.GetClientInfoByPlayerID(idRedistPlayer);
assert(pClrInfo);
// player info change: mark updated to remote clients get information
if (pClrInfo)
{
pClrInfo->SetUpdated();
}
}
}