Skip to content

Commit

Permalink
Fixed #2311
Browse files Browse the repository at this point in the history
  • Loading branch information
DjWarmonger authored and DjWarmonger committed Oct 24, 2015
1 parent 641aa13 commit 3c4f7ec
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions server/CGameHandler.cpp
Expand Up @@ -4808,10 +4808,12 @@ void CGameHandler::checkVictoryLossConditionsForPlayer(PlayerColor player)

//eliminating one player may cause victory of another:
std::set<PlayerColor> playerColors;
for (auto p : gs->players) //FIXME: players may have different colors, iterate by over players and not integers

//do not copy player state (CBonusSystemNode) by value
for (auto p = gs->players.begin(); p != gs->players.end(); p++) //players may have different colors, iterate over players and not integers
{
if (p.first != player)
playerColors.insert(p.first);
if (p->first != player)
playerColors.insert(p->first);
}

//notify all players
Expand Down

4 comments on commit 3c4f7ec

@alexvins
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we make CBonusSystemNode noncopyable?

@DjWarmonger
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I just thought about that, but not sure if in every case it will work as intended.

@alexvins
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

May be just add ":public boost::noncopyable" temporary and let compiler do it job.

@vmarkovtsev
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Guys, I think we should fix it like this:

for (auto& p : gs->players)
...

Note the amp after auto. It has the same effect as with iterator and avoids the unnecessary copying.

Please sign in to comment.