php 5.3 compatiblity

This commit is contained in:
kremsy
2014-04-20 14:52:26 +02:00
committed by Steffen Schröder
parent ea9c929ec3
commit 7408ffb4ac
11 changed files with 165 additions and 148 deletions

View File

@ -545,18 +545,19 @@ class MapList implements ManialinkPageAnswerListener, CallbackListener {
/** @var Map $map */
$votesPlugin->defineVote('switchmap', "Goto " . $map->name, true, $message);
$votesPlugin->startVote($player, 'switchmap', function ($result) use (&$votesPlugin, &$map) {
$this->maniaControl->chat->sendInformation('$sVote Successfully -> Map switched!');
$self = $this;
$votesPlugin->startVote($player, 'switchmap', function ($result) use (&$self, &$votesPlugin, &$map) {
$self->maniaControl->chat->sendInformation('$sVote Successfully -> Map switched!');
$votesPlugin->undefineVote('switchmap');
try {
$index = $this->maniaControl->mapManager->getMapIndex($map);
$this->maniaControl->client->jumpToMapIndex($index);
$index = $self->maniaControl->mapManager->getMapIndex($map);
$self->maniaControl->client->jumpToMapIndex($index);
} catch(Exception $e) {
//TODO temp added 19.04.2014
$this->maniaControl->errorHandler->triggerDebugNotice("Exception line 557 MapList.php" . $e->getMessage());
$self->maniaControl->errorHandler->triggerDebugNotice("Exception line 557 MapList.php" . $e->getMessage());
$this->maniaControl->chat->sendError("Error while Switching Map");
$self->maniaControl->chat->sendError("Error while Switching Map");
}
});
break;

View File

@ -586,27 +586,28 @@ class MapManager implements CallbackListener {
public function addMapFromMx($mapId, $login, $update = false) {
if (is_numeric($mapId)) {
// Check if map exists
$this->maniaControl->mapManager->mxManager->getMapInfo($mapId, function (MXMapInfo $mapInfo) use (&$login, &$update) {
$self = $this;
$this->maniaControl->mapManager->mxManager->getMapInfo($mapId, function (MXMapInfo $mapInfo) use (&$self, &$login, &$update) {
if (!$mapInfo || !isset($mapInfo->uploaded)) {
// Invalid id
$this->maniaControl->chat->sendError('Invalid MX-Id!', $login);
$self->maniaControl->chat->sendError('Invalid MX-Id!', $login);
return;
}
// TODO hardcoded during closed beta, later take just $mapInfo->url again
$url = 'http://' . $mapInfo->prefix . '.mania-exchange.com/' . $mapInfo->dir . '/download/' . $mapInfo->id;
if ($this->maniaControl->settingManager->getSetting($this->mxManager, ManiaExchangeManager::SETTING_MP3_BETA_TESTING)) {
if ($self->maniaControl->settingManager->getSetting($self->mxManager, ManiaExchangeManager::SETTING_MP3_BETA_TESTING)) {
$url .= '?key=t42kEMjzH7xpAjBFHAvEkC7rqAlw';
}
// Download the file
$this->maniaControl->fileReader->loadFile($url, function ($file, $error) use (&$login, &$mapInfo, &$update) {
$self->maniaControl->fileReader->loadFile($url, function ($file, $error) use (&$self, &$login, &$mapInfo, &$update) {
if (!$file) {
// Download error
$this->maniaControl->chat->sendError('Download failed!', $login);
$self->maniaControl->chat->sendError('Download failed!', $login);
return;
}
$this->processMapFile($file, $mapInfo, $login, $update);
$self->processMapFile($file, $mapInfo, $login, $update);
});
});
}