From d6cbba3d4b6bb78261629b7312a3826358a7c93e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Steffen=20Schro=CC=88der?= Date: Mon, 31 Mar 2014 21:54:29 +0200 Subject: [PATCH] fixed bug (getPlayer($shown) ???) improved coding --- application/core/Players/PlayerList.php | 27 +++++++++++++------------ 1 file changed, 14 insertions(+), 13 deletions(-) diff --git a/application/core/Players/PlayerList.php b/application/core/Players/PlayerList.php index 27490e8f..f91f2a77 100644 --- a/application/core/Players/PlayerList.php +++ b/application/core/Players/PlayerList.php @@ -767,20 +767,21 @@ class PlayerList implements ManialinkPageAnswerListener, CallbackListener, Timer * @param Player $player */ public function updateWidget(Player $player) { - foreach($this->playersListShown as $login => $shown) { - if ($shown) { - // Check if Shown player still exists - if ($shown != self::SHOWN_MAIN_WINDOW && $this->maniaControl->playerManager->getPlayer($shown) == null) { - $this->playersListShown[$login] = false; - } - $player = $this->maniaControl->playerManager->getPlayer($login); - if ($player) { - $this->showPlayerList($player); - } else { - // if player with the open widget disconnected remove him from the shownlist - unset($this->playersListShown[$login]); - } + foreach ($this->playersListShown as $login => $shown) { + if (!$shown) continue; + + // Check if shown player still exists + $player = $this->maniaControl->playerManager->getPlayer($login); + if (!$player) { + unset($this->playersListShown[$login]); + continue; } + + // Reopen widget + if ($shown != self::SHOWN_MAIN_WINDOW) { + $this->playersListShown[$login] = false; + } + $this->showPlayerList($player); } } } \ No newline at end of file