Skip to content

Commit

Permalink
Remove goto from Environment::removePlayer
Browse files Browse the repository at this point in the history
  • Loading branch information
Selat authored and ShadowNinja committed Mar 12, 2014
1 parent c9b6420 commit 2bc2ce3
Showing 1 changed file with 8 additions and 10 deletions.
18 changes: 8 additions & 10 deletions src/environment.cpp
Expand Up @@ -85,19 +85,17 @@ void Environment::addPlayer(Player *player)
void Environment::removePlayer(u16 peer_id)
{
DSTACK(__FUNCTION_NAME);
re_search:

for(std::list<Player*>::iterator i = m_players.begin();
i != m_players.end(); ++i)
i != m_players.end();)
{
Player *player = *i;
if(player->peer_id != peer_id)
continue;

delete player;
m_players.erase(i);
// See if there is an another one
// (shouldn't be, but just to be sure)
goto re_search;
if(player->peer_id == peer_id) {
delete player;
i = m_players.erase(i);
} else {
++i;
}
}
}

Expand Down

0 comments on commit 2bc2ce3

Please sign in to comment.