MapList fixed

This commit is contained in:
Max Klaversma 2014-04-29 22:30:29 +02:00 committed by Steffen Schröder
parent adfecf734e
commit 9b965a1720
2 changed files with 6 additions and 34 deletions

View File

@ -134,9 +134,10 @@ class MapList implements ManialinkPageAnswerListener, CallbackListener {
$mapList = array_slice($completeList, $chunk * self::MAX_PAGES_PER_CHUNK * self::MAX_MAPS_PER_PAGE, self::MAX_PAGES_PER_CHUNK * self::MAX_MAPS_PER_PAGE); $mapList = array_slice($completeList, $chunk * self::MAX_PAGES_PER_CHUNK * self::MAX_MAPS_PER_PAGE, self::MAX_PAGES_PER_CHUNK * self::MAX_MAPS_PER_PAGE);
$pageCount = ceil(count($completeList) / self::MAX_MAPS_PER_PAGE); $pageCount = ceil(count($completeList) / self::MAX_MAPS_PER_PAGE);
} }
else if ($maps !== 'redirect') { else {
$mapList = $this->maniaControl->mapManager->getMaps($chunk * self::MAX_PAGES_PER_CHUNK * self::MAX_MAPS_PER_PAGE, self::MAX_PAGES_PER_CHUNK * self::MAX_MAPS_PER_PAGE); $mapList = $this->maniaControl->mapManager->getMaps($chunk * self::MAX_PAGES_PER_CHUNK * self::MAX_MAPS_PER_PAGE, self::MAX_PAGES_PER_CHUNK * self::MAX_MAPS_PER_PAGE);
$pageCount = ceil($this->maniaControl->mapManager->getMapsCount() / self::MAX_MAPS_PER_PAGE); $pageCount = ceil($this->maniaControl->mapManager->getMapsCount() / self::MAX_MAPS_PER_PAGE);
$this->mapsInListShown[$player->login] = $this->maniaControl->mapManager->getMaps();
} }
// Create ManiaLink // Create ManiaLink
@ -144,7 +145,7 @@ class MapList implements ManialinkPageAnswerListener, CallbackListener {
$script = $maniaLink->getScript(); $script = $maniaLink->getScript();
$paging = new Paging(); $paging = new Paging();
$script->addFeature($paging); $script->addFeature($paging);
if (is_int($pageCount)) $paging->setCustomMaxPageNumber($pageCount); /*if (is_int($pageCount))*/ $paging->setCustomMaxPageNumber($pageCount);
$paging->setChunkActionAppendsPageNumber(true); $paging->setChunkActionAppendsPageNumber(true);
$paging->setChunkActions(self::ACTION_PAGING_CHUNKS); $paging->setChunkActions(self::ACTION_PAGING_CHUNKS);
@ -646,11 +647,11 @@ class MapList implements ManialinkPageAnswerListener, CallbackListener {
break; break;
case self::ACTION_QUEUED_MAP: case self::ACTION_QUEUED_MAP:
$this->maniaControl->mapManager->mapQueue->addMapToMapQueue($callback[1][1], $actionArray[2]); $this->maniaControl->mapManager->mapQueue->addMapToMapQueue($callback[1][1], $actionArray[2]);
$this->showMapList($player, 'redirect'); $this->showMapList($player);
break; break;
case self::ACTION_UNQUEUE_MAP: case self::ACTION_UNQUEUE_MAP:
$this->maniaControl->mapManager->mapQueue->removeFromMapQueue($player, $actionArray[2]); $this->maniaControl->mapManager->mapQueue->removeFromMapQueue($player, $actionArray[2]);
$this->showMapList($player, 'redirect'); $this->showMapList($player);
break; break;
default: default:
if (substr($actionId, 0, strlen(self::ACTION_PAGING_CHUNKS)) === self::ACTION_PAGING_CHUNKS) { if (substr($actionId, 0, strlen(self::ACTION_PAGING_CHUNKS)) === self::ACTION_PAGING_CHUNKS) {
@ -688,7 +689,7 @@ class MapList implements ManialinkPageAnswerListener, CallbackListener {
if ($shown) { if ($shown) {
$player = $this->maniaControl->playerManager->getPlayer($login); $player = $this->maniaControl->playerManager->getPlayer($login);
if ($player) { if ($player) {
$this->showMapList($player, 'redirect'); $this->showMapList($player);
} }
else { else {
unset($this->mapListShown[$login]); unset($this->mapListShown[$login]);

View File

@ -200,9 +200,6 @@ class Dedimania implements CallbackListener, CommandListener, TimerListener, Plu
* @param \ManiaControl\Players\Player $player * @param \ManiaControl\Players\Player $player
*/ */
public function handlePlayerConnect(Player $player) { public function handlePlayerConnect(Player $player) {
if (!$this->init) {
return;
}
// Send Dedimania request // Send Dedimania request
$data = array($this->dedimaniaData->sessionId, $player->login, $player->rawNickname, $player->path, $player->isSpectator); $data = array($this->dedimaniaData->sessionId, $player->login, $player->rawNickname, $player->path, $player->isSpectator);
$content = $this->encode_request(self::DEDIMANIA_PLAYERCONNECT, $data); $content = $this->encode_request(self::DEDIMANIA_PLAYERCONNECT, $data);
@ -248,9 +245,6 @@ class Dedimania implements CallbackListener, CommandListener, TimerListener, Plu
* @param \ManiaControl\Players\Player $player * @param \ManiaControl\Players\Player $player
*/ */
public function handlePlayerDisconnect(Player $player) { public function handlePlayerDisconnect(Player $player) {
if (!$this->init) {
return;
}
$this->dedimaniaData->removePlayer($player->login); $this->dedimaniaData->removePlayer($player->login);
// Send Dedimania request // Send Dedimania request
@ -286,9 +280,6 @@ class Dedimania implements CallbackListener, CommandListener, TimerListener, Plu
* @param $callback * @param $callback
*/ */
public function handleBeginMap($callback) { public function handleBeginMap($callback) {
if (!$this->init) {
return;
}
unset($this->dedimaniaData->records); unset($this->dedimaniaData->records);
$this->fetchDedimaniaRecords(true); $this->fetchDedimaniaRecords(true);
} }
@ -300,9 +291,6 @@ class Dedimania implements CallbackListener, CommandListener, TimerListener, Plu
* @param $callback * @param $callback
*/ */
public function handleMapEnd($callback) { public function handleMapEnd($callback) {
if (!$this->init) {
return;
}
if (!$this->dedimaniaData || !$this->dedimaniaData->records) { if (!$this->dedimaniaData || !$this->dedimaniaData->records) {
return; return;
} }
@ -381,9 +369,6 @@ class Dedimania implements CallbackListener, CommandListener, TimerListener, Plu
* @param $callback * @param $callback
*/ */
public function updatePlayerList($callback) { public function updatePlayerList($callback) {
if (!$this->init) {
return;
}
$serverInfo = $this->getServerInfo(); $serverInfo = $this->getServerInfo();
$playerList = $this->getPlayerList(); $playerList = $this->getPlayerList();
$votesInfo = $this->getVotesInfo(); $votesInfo = $this->getVotesInfo();
@ -424,9 +409,6 @@ class Dedimania implements CallbackListener, CommandListener, TimerListener, Plu
* @param $callback * @param $callback
*/ */
public function handlePlayerCheckpoint($callback) { public function handlePlayerCheckpoint($callback) {
if (!$this->init) {
return;
}
$data = $callback[1]; $data = $callback[1];
$login = $data[1]; $login = $data[1];
$time = $data[2]; $time = $data[2];
@ -444,9 +426,6 @@ class Dedimania implements CallbackListener, CommandListener, TimerListener, Plu
* @param $callback * @param $callback
*/ */
public function handlePlayerFinished($callback) { public function handlePlayerFinished($callback) {
if (!$this->init) {
return;
}
//var_dump($callback); //var_dump($callback);
$data = $callback[1]; $data = $callback[1];
if ($data[0] <= 0 || $data[2] <= 0) { if ($data[0] <= 0 || $data[2] <= 0) {
@ -619,10 +598,6 @@ class Dedimania implements CallbackListener, CommandListener, TimerListener, Plu
return false; return false;
} }
if (!$this->init) {
return;
}
// Reset records // Reset records
if ($reset) { if ($reset) {
$this->dedimaniaData->records = array(); $this->dedimaniaData->records = array();
@ -948,10 +923,6 @@ class Dedimania implements CallbackListener, CommandListener, TimerListener, Plu
* @return array|RecordData * @return array|RecordData
*/ */
public function getDedimaniaRecords() { public function getDedimaniaRecords() {
if (!$this->init) {
return false;
}
if (!$this->dedimaniaData->records) { if (!$this->dedimaniaData->records) {
return null; return null;
} }