From 6193787ee57649018118d5a9ac789acac1c3ab32 Mon Sep 17 00:00:00 2001 From: kremsy Date: Fri, 19 May 2017 18:35:33 +0200 Subject: [PATCH] mc plugin increase --- core/ManiaControl.php | 2 +- core/ManiaExchange/ManiaExchangeList.php | 12 +++++++++++- core/ManiaExchange/ManiaExchangeMapSearch.php | 12 ++---------- 3 files changed, 14 insertions(+), 12 deletions(-) diff --git a/core/ManiaControl.php b/core/ManiaControl.php index 7d0b9094..5849ad51 100644 --- a/core/ManiaControl.php +++ b/core/ManiaControl.php @@ -52,7 +52,7 @@ class ManiaControl implements CallbackListener, CommandListener, TimerListener, /* * Constants */ - const VERSION = '0.217'; + const VERSION = '0.218'; const API_VERSION = '2013-04-16'; const MIN_DEDIVERSION = '2017-05-03_21_00'; const SCRIPT_TIMEOUT = 40; diff --git a/core/ManiaExchange/ManiaExchangeList.php b/core/ManiaExchange/ManiaExchangeList.php index df50c202..3d9af038 100644 --- a/core/ManiaExchange/ManiaExchangeList.php +++ b/core/ManiaExchange/ManiaExchangeList.php @@ -129,7 +129,6 @@ class ManiaExchangeList implements CallbackListener, ManialinkPageAnswerListener } } } - $this->getMXMapsAndShowList($player, $author, $environment, $searchString); } @@ -142,6 +141,17 @@ class ManiaExchangeList implements CallbackListener, ManialinkPageAnswerListener * @param string $searchString */ private function getMXMapsAndShowList(Player $player, $author = '', $environment = '', $searchString = '') { + //TODO do more clean solution + if($environment == ""){ + $titleId = $this->maniaControl->getServer()->titleId; + //Set Environments on Trackmania + $game = explode('@', $titleId); + $envNumber = ManiaExchangeMapSearch::getEnvironment($game[0]); //TODO enviroment as constant + if ($envNumber > -1) { + $environment = $envNumber; + } + } + //Search the Maps $mxSearch = new ManiaExchangeMapSearch($this->maniaControl); $mxSearch->setAuthorName($author); diff --git a/core/ManiaExchange/ManiaExchangeMapSearch.php b/core/ManiaExchange/ManiaExchangeMapSearch.php index b89c947e..c23e32f3 100644 --- a/core/ManiaExchange/ManiaExchangeMapSearch.php +++ b/core/ManiaExchange/ManiaExchangeMapSearch.php @@ -100,8 +100,6 @@ class ManiaExchangeMapSearch implements UsageInformationAble { public function __construct(ManiaControl $maniaControl) { $this->maniaControl = $maniaControl; - - $titleId = $this->maniaControl->getServer()->titleId; $this->titlePrefix = $this->maniaControl->getMapManager()->getCurrentMap()->getGame(); $this->url = 'https://' . $this->titlePrefix . '.mania-exchange.com/tracksearch2/search?api=on'; @@ -129,12 +127,6 @@ class ManiaExchangeMapSearch implements UsageInformationAble { } catch (GameModeException $e) { } - //Set Environments on Trackmania - $game = explode('@', $titleId); - $envNumber = $this->getEnvironment($game[0]); //TODO enviroment as constant - if ($envNumber > -1) { - $this->environments = $envNumber; - } } /** @@ -186,7 +178,7 @@ class ManiaExchangeMapSearch implements UsageInformationAble { $parameters .= "&secord=" . $this->secondaryOrder; } if ($this->environments) { - $parameters .= "&environemtns=" . $this->environments; + $parameters .= "&environments=" . $this->environments; } if ($this->vehicles) { $parameters .= "&vehicles=" . $this->vehicles; @@ -270,7 +262,7 @@ class ManiaExchangeMapSearch implements UsageInformationAble { * @param string $env * @return int */ - private function getEnvironment($env) { + public static function getEnvironment($env) { switch ($env) { case 'TMCanyon': return 1;