aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSelat <LongExampleTestName@gmail.com>2014-03-05 18:14:40 +0300
committerShadowNinja <shadowninja@minetest.net>2014-03-12 17:02:52 -0400
commit2bc2ce3bd159cc7aa7054059ad413e93d05d0211 (patch)
tree51b9c686c0b76c294c0ac40d022d87a50cbf9084
parentc9b64206f9cc4f9332cc903816799fcafb4fb7c9 (diff)
downloadminetest-2bc2ce3bd159cc7aa7054059ad413e93d05d0211.tar.gz
minetest-2bc2ce3bd159cc7aa7054059ad413e93d05d0211.tar.bz2
minetest-2bc2ce3bd159cc7aa7054059ad413e93d05d0211.zip
Remove goto from Environment::removePlayer
-rw-r--r--src/environment.cpp18
1 files 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<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;
+ }
}
}