From 2bc2ce3bd159cc7aa7054059ad413e93d05d0211 Mon Sep 17 00:00:00 2001 From: Selat Date: Wed, 5 Mar 2014 18:14:40 +0300 Subject: [PATCH] Remove goto from Environment::removePlayer --- src/environment.cpp | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/src/environment.cpp b/src/environment.cpp index 3593c94f0..4b8425774 100644 --- a/src/environment.cpp +++ b/src/environment.cpp @@ -85,19 +85,17 @@ void Environment::addPlayer(Player *player) void Environment::removePlayer(u16 peer_id) { DSTACK(__FUNCTION_NAME); -re_search: + for(std::list::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; + } } } -- 2.25.1