Remove goto from Environment::removePlayer
authorSelat <LongExampleTestName@gmail.com>
Wed, 5 Mar 2014 15:14:40 +0000 (18:14 +0300)
committerShadowNinja <shadowninja@minetest.net>
Wed, 12 Mar 2014 21:02:52 +0000 (17:02 -0400)
src/environment.cpp

index 3593c94f05e740fb916d12c074c19e1c107cc516..4b84257742c34bd7e92e8db911640ff311ed24e3 100644 (file)
@@ -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;
+               }
        }
 }