fixed bug (getPlayer($shown) ???)

improved coding
This commit is contained in:
Steffen Schröder 2014-03-31 21:54:29 +02:00
parent 2c066f7b62
commit d6cbba3d4b

View File

@ -768,19 +768,20 @@ class PlayerList implements ManialinkPageAnswerListener, CallbackListener, Timer
*/
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) {
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;
}
$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]);
}
}
}
}
}