Skip to content

Commit

Permalink
Assign a player an unused player color if the default color is alread…
Browse files Browse the repository at this point in the history
…y taken
  • Loading branch information
axatin authored and RecursiveVision committed May 25, 2024
1 parent 3e69743 commit 196a618
Showing 1 changed file with 15 additions and 2 deletions.
17 changes: 15 additions & 2 deletions CvGameCoreDLL_Expansion2/CvGame.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -674,8 +674,21 @@ void CvGame::InitPlayers()
else if (iI < MAX_MAJOR_CIVS)
{
const PlayerTypes eLoopPlayer = static_cast<PlayerTypes>(iI);
CvPreGame::setPlayerColor(eLoopPlayer, aePlayerColors[iI]);

PlayerColorTypes ePlayerColor = aePlayerColors[iI];
if (ePlayerColor == NO_PLAYERCOLOR)
{
// search for an unused player color
for (int iK = 0; iK < GC.GetNumPlayerColorInfos(); iK++)
{
if (std::find(vColorsAlreadyUsed.begin(), vColorsAlreadyUsed.end(), (PlayerColorTypes)iK) == vColorsAlreadyUsed.end())
{
ePlayerColor = (PlayerColorTypes)iK;
vColorsAlreadyUsed.push_back(ePlayerColor);
break;
}
}
}
CvPreGame::setPlayerColor(eLoopPlayer, ePlayerColor);
// Make sure the AI has the proper handicap.
if (CvPreGame::slotStatus(eLoopPlayer) == SS_COMPUTER)
CvPreGame::setHandicap(eLoopPlayer, eAIHandicap);
Expand Down

0 comments on commit 196a618

Please sign in to comment.