some fixes
This commit is contained in:
parent
f40b60e065
commit
dfb9debdd2
@ -28,7 +28,7 @@ class AsynchronousFileReader implements TimerListener {
|
||||
public function appendData() {
|
||||
foreach($this->sockets as $key => &$socket) {
|
||||
/** @var SocketStructure $socket */
|
||||
$socket->streamBuffer .= fread($socket->socket, 512);
|
||||
$socket->streamBuffer .= fread($socket->socket, 1024);
|
||||
$info = stream_get_meta_data($socket->socket);
|
||||
|
||||
if (feof($socket->socket) || $info['timed_out']) {
|
||||
|
@ -58,29 +58,23 @@ class ManiaExchangeList implements CallbackListener, ManialinkPageAnswerListener
|
||||
$this->maniaControl->callbackManager->registerCallbackListener(ManialinkManager::CB_MAIN_WINDOW_OPENED, $this, 'handleWidgetOpened');
|
||||
$this->maniaControl->callbackManager->registerCallbackListener(CallbackManager::CB_MP_PLAYERMANIALINKPAGEANSWER, $this, 'handleManialinkPageAnswer');
|
||||
|
||||
$this->maniaControl->manialinkManager->registerManialinkPageAnswerListener(self::ACTION_SEARCH_MAPNAME, $this, 'showManiaExchangeList');
|
||||
$this->maniaControl->manialinkManager->registerManialinkPageAnswerListener(self::ACTION_SEARCH_AUTHOR, $this, 'showManiaExchangeList');
|
||||
$this->maniaControl->manialinkManager->registerManialinkPageAnswerListener(self::ACTION_SEARCH_MAPNAME, $this, 'showList');
|
||||
$this->maniaControl->manialinkManager->registerManialinkPageAnswerListener(self::ACTION_SEARCH_AUTHOR, $this, 'showList');
|
||||
}
|
||||
|
||||
|
||||
public function showList(array $chatCallback, Player $player) {
|
||||
$this->showManiaExchangeList($chatCallback, $player);
|
||||
}
|
||||
|
||||
/**
|
||||
* Display the Mania Exchange List
|
||||
* Shows the List
|
||||
*
|
||||
* @param array $chatCallback
|
||||
* @param Player $player
|
||||
*/
|
||||
public function showManiaExchangeList(array $chatCallback, Player $player) {
|
||||
public function showList(array $chatCallback, Player $player) {
|
||||
$this->mapListShown[$player->login] = true;
|
||||
|
||||
$params = explode(' ', $chatCallback[1][2]);
|
||||
|
||||
$searchString = '';
|
||||
$author = '';
|
||||
$environment = '';
|
||||
$params = explode(' ', $chatCallback[1][2]);
|
||||
$searchString = '';
|
||||
$author = '';
|
||||
$environment = '';
|
||||
if (count($params) >= 1) {
|
||||
foreach($params as $param) {
|
||||
if ($param == '/xlist' || $param == MapCommands::ACTION_OPEN_XLIST) {
|
||||
@ -105,14 +99,22 @@ class ManiaExchangeList implements CallbackListener, ManialinkPageAnswerListener
|
||||
}
|
||||
|
||||
// search for matching maps
|
||||
$maps = $this->maniaControl->mapManager->mxManager->getMaps($searchString, $author, $environment);
|
||||
|
||||
// check if there are any results
|
||||
if ($maps == null) {
|
||||
$this->maniaControl->chat->sendError('No maps found, or MX is down!', $player->login);
|
||||
return;
|
||||
}
|
||||
$this->maniaControl->mapManager->mxManager->getMapsAssync(function ($maps) use (&$player) {
|
||||
if ($maps == null) {
|
||||
$this->maniaControl->chat->sendError('No maps found, or MX is down!', $player->login);
|
||||
return;
|
||||
}
|
||||
$this->showManiaExchangeList($maps, $player);
|
||||
}, $searchString, $author, $environment);
|
||||
}
|
||||
|
||||
/**
|
||||
* Display the Mania Exchange List
|
||||
*
|
||||
* @param array $chatCallback
|
||||
* @param Player $player
|
||||
*/
|
||||
private function showManiaExchangeList($maps, Player $player) {
|
||||
// Start offsets
|
||||
$width = $this->maniaControl->manialinkManager->styleManager->getListWidgetsWidth();
|
||||
$height = $this->maniaControl->manialinkManager->styleManager->getListWidgetsHeight();
|
||||
@ -293,7 +295,7 @@ class ManiaExchangeList implements CallbackListener, ManialinkPageAnswerListener
|
||||
switch($action) {
|
||||
case self::ACTION_GET_MAPS_FROM_AUTHOR:
|
||||
$callback[1][2] = 'auth:' . $actionArray[2];
|
||||
$this->showManiaExchangeList($callback, $player);
|
||||
$this->showList($callback, $player);
|
||||
break;
|
||||
case self::ACTION_ADD_MAP:
|
||||
$this->maniaControl->mapManager->addMapFromMx($mapId, $player->login);
|
||||
|
@ -251,7 +251,7 @@ class ManiaExchangeManager {
|
||||
return $success;
|
||||
}
|
||||
|
||||
/*public function getMapsAssync($function, $name = '', $author = '', $env = '', $maxMapsReturned = 100, $searchOrder = self::SEARCH_ORDER_UPDATED_NEWEST) {
|
||||
public function getMapsAssync($function, $name = '', $author = '', $env = '', $maxMapsReturned = 100, $searchOrder = self::SEARCH_ORDER_UPDATED_NEWEST) {
|
||||
if (!is_callable($function)) {
|
||||
$this->maniaControl->log("Function is not callable");
|
||||
return false;
|
||||
@ -312,7 +312,7 @@ class ManiaExchangeManager {
|
||||
}
|
||||
|
||||
return $success;
|
||||
}*/
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
|
@ -238,6 +238,6 @@ class MapCommands implements CommandListener, ManialinkPageAnswerListener, Callb
|
||||
* @param Player $player
|
||||
*/
|
||||
public function command_xList(array $chatCallback, Player $player) {
|
||||
$this->maniaControl->mapManager->mxList->showManiaExchangeList($chatCallback, $player);
|
||||
$this->maniaControl->mapManager->mxList->showList($chatCallback, $player);
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user