From 95a6e3e6a39899b0394a3b24e0f6b6401025f515 Mon Sep 17 00:00:00 2001 From: kremsy Date: Mon, 19 Jan 2015 19:18:26 +0100 Subject: [PATCH 01/97] small cleanup help-manager --- core/Commands/HelpManager.php | 67 +++++++++++++++++------------------ 1 file changed, 32 insertions(+), 35 deletions(-) diff --git a/core/Commands/HelpManager.php b/core/Commands/HelpManager.php index 4dac4125..6ccaa7b4 100644 --- a/core/Commands/HelpManager.php +++ b/core/Commands/HelpManager.php @@ -19,15 +19,14 @@ use ManiaControl\Players\Player; * @copyright 2014-2015 ManiaControl Team * @license http://www.gnu.org/licenses/ GNU General Public License, Version 3 */ - class HelpManager implements CommandListener, CallbackListener { /* * Private properties */ /** @var ManiaControl $maniaControl */ - private $maniaControl = null; + private $maniaControl = null; private $playerCommands = array(); - private $adminCommands = array(); + private $adminCommands = array(); /** * Construct a new Commands Manager @@ -58,14 +57,14 @@ class HelpManager implements CommandListener, CallbackListener { * @param Player $player */ public function command_adminHelp(array $chatCallback, Player $player) { - // Parse list from array - $message = $this->parseHelpList($this->adminCommands); - - // Show message when it's not empty - if($message != NULL){ - $message = 'Supported Admin Commands: ' . $message; - $this->maniaControl->getChat()->sendChat($message, $player); - } + // Parse list from array + $message = $this->parseHelpList($this->adminCommands); + + // Show message when it's not empty + if ($message != null) { + $message = 'Supported Admin Commands: ' . $message; + $this->maniaControl->getChat()->sendChat($message, $player); + } } /** @@ -75,14 +74,14 @@ class HelpManager implements CommandListener, CallbackListener { * @param Player $player */ public function command_playerHelp(array $chatCallback, Player $player) { - // Parse list from array + // Parse list from array $message = $this->parseHelpList($this->playerCommands); - - // Show message when it's not empty - if($message != NULL){ - $message = 'Supported Player Commands: ' . $message; - $this->maniaControl->getChat()->sendChat($message, $player); - } + + // Show message when it's not empty + if ($message != null) { + $message = 'Supported Player Commands: ' . $message; + $this->maniaControl->getChat()->sendChat($message, $player); + } } /** @@ -92,23 +91,24 @@ class HelpManager implements CommandListener, CallbackListener { * @param Player $player */ public function command_playerHelpAll(array $chatCallback, Player $player) { - $this->parseHelpList($this->playerCommands, true, $player); + $this->parseHelpList($this->playerCommands, true, $player); } /** - * Parse list with commands from array - * @param array $commands - * @param bool $isHelpAll - * @param Player $player - * @return string|void - */ + * Parse list with commands from array + * + * @param array $commands + * @param bool $isHelpAll + * @param Player $player + * @return string|void + */ private function parseHelpList(array $commands, $isHelpAll = false, Player $player = null) { $showCommands = array(); $registeredMethods = array(); - $message = ''; + $message = ''; foreach (array_reverse($commands) as $command) { if (array_key_exists($command['Method'], $registeredMethods)) { - if($showCommands[$registeredMethods[$command['Method']]]['Description'] === $command['Description']) { + if ($showCommands[$registeredMethods[$command['Method']]]['Description'] === $command['Description']) { $name = $registeredMethods[$command['Method']]; $showCommands[$name]['Name'] .= '|' . $command['Name']; } else { @@ -125,20 +125,17 @@ class HelpManager implements CommandListener, CallbackListener { return strcmp($commandA['Name'], $commandB['Name']); }); - if(!$isHelpAll){ + if (!$isHelpAll) { foreach ($showCommands as $command) { $message .= $command['Name'] . ','; } $message = substr($message, 0, -1); - - return $message; - }else{ - if($player != NULL){ + } else { + if ($player != null) { $this->showHelpAllList($showCommands, $player); } } - - return; + return $message; } /** @@ -221,7 +218,7 @@ class HelpManager implements CommandListener, CallbackListener { * @param Player $player */ public function command_adminHelpAll(array $chatCallback, Player $player) { - $this->parseHelpList($this->adminCommands, true, $player); + $this->parseHelpList($this->adminCommands, true, $player); } /** From de97efaa00b2ffba9dca37ffeab10b677b2ed541 Mon Sep 17 00:00:00 2001 From: kremsy Date: Wed, 21 Jan 2015 17:06:18 +0100 Subject: [PATCH 02/97] added mania exchange constants --- core/ManiaExchange/ManiaExchangeManager.php | 22 +++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) diff --git a/core/ManiaExchange/ManiaExchangeManager.php b/core/ManiaExchange/ManiaExchangeManager.php index 869efbec..a47223a8 100644 --- a/core/ManiaExchange/ManiaExchangeManager.php +++ b/core/ManiaExchange/ManiaExchangeManager.php @@ -19,7 +19,7 @@ class ManiaExchangeManager { /* * Constants */ - //Search others + //Search orders (prior parameter) http://api.mania-exchange.com/documents/enums#orderings const SEARCH_ORDER_NONE = -1; const SEARCH_ORDER_TRACK_NAME = 0; const SEARCH_ORDER_AUTHOR = 1; @@ -37,6 +37,24 @@ class ManiaExchangeManager { const SEARCH_ORDER_DIFFICULTY_HARDEST = 13; const SEARCH_ORDER_LENGTH_SHORTEST = 14; const SEARCH_ORDER_LENGTH_LONGEST = 15; + const SEARCH_ORDER_TRACK_VALUE_LTH = 24; + const SEARCH_ORDER_TRACK_VALUE_HTL = 25; + const SEARCH_ORDER_ONLINE_RATING_LTH = 26; + const SEARCH_ORDER_ONLINE_RATING_HTL = 27; + + //Special Search Orders (mode parameter): http://api.mania-exchange.com/documents/enums#modes + const SEARCH_ORDER_SPECIAL_DEFAULT = 0; + const SEARCH_ORDER_SPECIAL_USER_TRACKS = 1; + const SEARCH_ORDER_SPECIAL_LATEST_TRACKS = 2; + const SEARCH_ORDER_SPECIAL_RECENTLY_AWARDED = 3; + const SEARCH_ORDER_SPECIAL_BEST_OF_WEEK_AWARDS = 4; + const SEARCH_ORDER_SPECIAL_BEST_OF_MONTH_AWARDS = 5; + const SEARCH_ORDER_SPECIAL_MX_SUPPORTER_TRACKS = 10; + const SEARCH_ORDER_SPECIAL_DUO_ACCOUNT_TRACKS = 11; + const SEARCH_ORDER_SPECIAL_MOST_COMPETITIVE_WEEK = 19; + const SEARCH_ORDER_SPECIAL_MOST_COMPETITIVE_MONTH = 20; + const SEARCH_ORDER_SPECIAL_BEST_ONLINE_RATING_WEEK = 21; + const SEARCH_ORDER_SPECIAL_BEST_ONLINE_RATING_MONTH = 22; //Maximum Maps per request const MAPS_PER_MX_FETCH = 50; @@ -47,7 +65,7 @@ class ManiaExchangeManager { * Private properties */ /** @var ManiaControl $maniaControl */ - private $maniaControl = null; + private $maniaControl = null; private $mxIdUidVector = array(); /** From 8419498959583eb727f1e1c164a6386557657504 Mon Sep 17 00:00:00 2001 From: kremsy Date: Wed, 21 Jan 2015 17:26:08 +0100 Subject: [PATCH 03/97] added todo --- core/ManiaExchange/ManiaExchangeManager.php | 1 + 1 file changed, 1 insertion(+) diff --git a/core/ManiaExchange/ManiaExchangeManager.php b/core/ManiaExchange/ManiaExchangeManager.php index a47223a8..5c250dfa 100644 --- a/core/ManiaExchange/ManiaExchangeManager.php +++ b/core/ManiaExchange/ManiaExchangeManager.php @@ -305,6 +305,7 @@ class ManiaExchangeManager { * @param int $searchOrder */ public function fetchMapsAsync(callable $function, $name = '', $author = '', $env = '', $maxMapsReturned = 100, $searchOrder = self::SEARCH_ORDER_UPDATED_NEWEST) { + //TODO provide additional parameters as array, generally new structure // TODO: remove $env because it's not really used? // Get Title Id From 97f4d44202e8ed2d9e9b664dec8d30bef1280e1c Mon Sep 17 00:00:00 2001 From: kremsy Date: Wed, 21 Jan 2015 17:47:29 +0100 Subject: [PATCH 04/97] display mx karma in maplist --- core/Maps/MapCommands.php | 12 +++++++++++- core/Maps/MapList.php | 19 +++++++++++++++---- 2 files changed, 26 insertions(+), 5 deletions(-) diff --git a/core/Maps/MapCommands.php b/core/Maps/MapCommands.php index c2a04c61..59767037 100644 --- a/core/Maps/MapCommands.php +++ b/core/Maps/MapCommands.php @@ -436,8 +436,18 @@ class MapCommands implements CommandListener, ManialinkPageAnswerListener, Callb */ private function showMapListKarma($best, Player $player) { /** @var \MCTeam\KarmaPlugin $karmaPlugin */ - $karmaPlugin = $this->maniaControl->getPluginManager()->getPlugin(MapList::DEFAULT_KARMA_PLUGIN); + $karmaPlugin = $this->maniaControl->getPluginManager()->getPlugin(MapList::DEFAULT_KARMA_PLUGIN); + $displayMxKarma = $this->maniaControl->getSettingManager()->getSettingValue($karmaPlugin, $karmaPlugin::SETTING_WIDGET_DISPLAY_MX); + if ($karmaPlugin) { + //Sort by Mx Karma in Maplist + if ($displayMxKarma) { //TODO + + //Sort by Local Karma in Maplist + } else { + + } + $maps = $this->maniaControl->getMapManager()->getMaps(); $mapList = array(); foreach ($maps as $map) { diff --git a/core/Maps/MapList.php b/core/Maps/MapList.php index 022cd1bb..8246d009 100644 --- a/core/Maps/MapList.php +++ b/core/Maps/MapList.php @@ -122,7 +122,7 @@ class MapList implements ManialinkPageAnswerListener, CallbackListener { $height = $this->maniaControl->getManialinkManager()->getStyleManager()->getListWidgetsHeight(); if ($pageIndex < 0) { - $pageIndex = (int)$player->getCache($this, self::CACHE_CURRENT_PAGE); + $pageIndex = (int) $player->getCache($this, self::CACHE_CURRENT_PAGE); } $player->setCache($this, self::CACHE_CURRENT_PAGE, $pageIndex); $queueBuffer = $this->maniaControl->getMapManager()->getMapQueue()->getQueueBuffer(); @@ -441,8 +441,19 @@ class MapList implements ManialinkPageAnswerListener, CallbackListener { // Display Karma bar if ($karmaPlugin) { - $karma = $karmaPlugin->getMapKarma($map); - $votes = $karmaPlugin->getMapVotes($map); + $displayMxKarma = $this->maniaControl->getSettingManager()->getSettingValue($karmaPlugin, $karmaPlugin::SETTING_WIDGET_DISPLAY_MX); + + //Display Mx Karma + if ($displayMxKarma && $map->mx) { + $karma = $map->mx->ratingVoteAverage / 100; + $votes = array("count" => $map->mx->ratingVoteCount); + + //Display Local Karma + } else { + $karma = $karmaPlugin->getMapKarma($map); + $votes = $karmaPlugin->getMapVotes($map); + } + if (is_numeric($karma)) { if ($this->maniaControl->getSettingManager()->getSettingValue($karmaPlugin, $karmaPlugin::SETTING_NEWKARMA) ) { @@ -692,7 +703,7 @@ class MapList implements ManialinkPageAnswerListener, CallbackListener { default: if (substr($actionId, 0, strlen(self::ACTION_PAGING_CHUNKS)) === self::ACTION_PAGING_CHUNKS) { // Paging chunks - $neededPage = (int)substr($actionId, strlen(self::ACTION_PAGING_CHUNKS)); + $neededPage = (int) substr($actionId, strlen(self::ACTION_PAGING_CHUNKS)); $this->showMapList($player, null, $neededPage - 1); } break; From 385bcebac7b34ee0b09b80a075010957338e023e Mon Sep 17 00:00:00 2001 From: kremsy Date: Wed, 21 Jan 2015 20:37:25 +0100 Subject: [PATCH 05/97] begin maniaexchange mapsearcher class --- core/ManiaExchange/ManiaExchangeManager.php | 21 +- core/ManiaExchange/ManiaExchangeMapSearch.php | 358 ++++++++++++++++++ 2 files changed, 360 insertions(+), 19 deletions(-) create mode 100644 core/ManiaExchange/ManiaExchangeMapSearch.php diff --git a/core/ManiaExchange/ManiaExchangeManager.php b/core/ManiaExchange/ManiaExchangeManager.php index 5c250dfa..8dbed022 100644 --- a/core/ManiaExchange/ManiaExchangeManager.php +++ b/core/ManiaExchange/ManiaExchangeManager.php @@ -9,7 +9,7 @@ use ManiaControl\Maps\MapManager; use Maniaplanet\DedicatedServer\Xmlrpc\GameModeException; /** - * Mania Exchange Info Searcher Class + * Mania Exchange Manager Class * * @author ManiaControl Team * @copyright 2014-2015 ManiaControl Team @@ -18,6 +18,7 @@ use Maniaplanet\DedicatedServer\Xmlrpc\GameModeException; class ManiaExchangeManager { /* * Constants + * @deprecated SEARCH Constants */ //Search orders (prior parameter) http://api.mania-exchange.com/documents/enums#orderings const SEARCH_ORDER_NONE = -1; @@ -37,24 +38,6 @@ class ManiaExchangeManager { const SEARCH_ORDER_DIFFICULTY_HARDEST = 13; const SEARCH_ORDER_LENGTH_SHORTEST = 14; const SEARCH_ORDER_LENGTH_LONGEST = 15; - const SEARCH_ORDER_TRACK_VALUE_LTH = 24; - const SEARCH_ORDER_TRACK_VALUE_HTL = 25; - const SEARCH_ORDER_ONLINE_RATING_LTH = 26; - const SEARCH_ORDER_ONLINE_RATING_HTL = 27; - - //Special Search Orders (mode parameter): http://api.mania-exchange.com/documents/enums#modes - const SEARCH_ORDER_SPECIAL_DEFAULT = 0; - const SEARCH_ORDER_SPECIAL_USER_TRACKS = 1; - const SEARCH_ORDER_SPECIAL_LATEST_TRACKS = 2; - const SEARCH_ORDER_SPECIAL_RECENTLY_AWARDED = 3; - const SEARCH_ORDER_SPECIAL_BEST_OF_WEEK_AWARDS = 4; - const SEARCH_ORDER_SPECIAL_BEST_OF_MONTH_AWARDS = 5; - const SEARCH_ORDER_SPECIAL_MX_SUPPORTER_TRACKS = 10; - const SEARCH_ORDER_SPECIAL_DUO_ACCOUNT_TRACKS = 11; - const SEARCH_ORDER_SPECIAL_MOST_COMPETITIVE_WEEK = 19; - const SEARCH_ORDER_SPECIAL_MOST_COMPETITIVE_MONTH = 20; - const SEARCH_ORDER_SPECIAL_BEST_ONLINE_RATING_WEEK = 21; - const SEARCH_ORDER_SPECIAL_BEST_ONLINE_RATING_MONTH = 22; //Maximum Maps per request const MAPS_PER_MX_FETCH = 50; diff --git a/core/ManiaExchange/ManiaExchangeMapSearch.php b/core/ManiaExchange/ManiaExchangeMapSearch.php new file mode 100644 index 00000000..b25370e6 --- /dev/null +++ b/core/ManiaExchange/ManiaExchangeMapSearch.php @@ -0,0 +1,358 @@ + + * @copyright 2014-2015 ManiaControl Team + * @license http://www.gnu.org/licenses/ GNU General Public License, Version 3 + */ +class ManiaExchangeMapSearch { + //Search orders (prior parameter) http://api.mania-exchange.com/documents/enums#orderings + const SEARCH_ORDER_NONE = -1; + const SEARCH_ORDER_TRACK_NAME = 0; + const SEARCH_ORDER_AUTHOR = 1; + const SEARCH_ORDER_UPLOADED_NEWEST = 2; + const SEARCH_ORDER_UPLOADED_OLDEST = 3; + const SEARCH_ORDER_UPDATED_NEWEST = 4; + const SEARCH_ORDER_UPDATED_OLDEST = 5; + const SEARCH_ORDER_ACTIVITY_LATEST = 6; + const SEARCH_ORDER_ACTIVITY_OLDEST = 7; + const SEARCH_ORDER_AWARDS_MOST = 8; + const SEARCH_ORDER_AWARDS_LEAST = 9; + const SEARCH_ORDER_COMMENTS_MOST = 10; + const SEARCH_ORDER_COMMENTS_LEAST = 11; + const SEARCH_ORDER_DIFFICULTY_EASIEST = 12; + const SEARCH_ORDER_DIFFICULTY_HARDEST = 13; + const SEARCH_ORDER_LENGTH_SHORTEST = 14; + const SEARCH_ORDER_LENGTH_LONGEST = 15; + const SEARCH_ORDER_TRACK_VALUE_LTH = 24; + const SEARCH_ORDER_TRACK_VALUE_HTL = 25; + const SEARCH_ORDER_ONLINE_RATING_LTH = 26; + const SEARCH_ORDER_ONLINE_RATING_HTL = 27; + + //Special Search Orders (mode parameter): http://api.mania-exchange.com/documents/enums#modes + const SEARCH_ORDER_SPECIAL_DEFAULT = 0; + const SEARCH_ORDER_SPECIAL_USER_TRACKS = 1; + const SEARCH_ORDER_SPECIAL_LATEST_TRACKS = 2; + const SEARCH_ORDER_SPECIAL_RECENTLY_AWARDED = 3; + const SEARCH_ORDER_SPECIAL_BEST_OF_WEEK_AWARDS = 4; + const SEARCH_ORDER_SPECIAL_BEST_OF_MONTH_AWARDS = 5; + const SEARCH_ORDER_SPECIAL_MX_SUPPORTER_TRACKS = 10; + const SEARCH_ORDER_SPECIAL_DUO_ACCOUNT_TRACKS = 11; + const SEARCH_ORDER_SPECIAL_MOST_COMPETITIVE_WEEK = 19; + const SEARCH_ORDER_SPECIAL_MOST_COMPETITIVE_MONTH = 20; + const SEARCH_ORDER_SPECIAL_BEST_ONLINE_RATING_WEEK = 21; + const SEARCH_ORDER_SPECIAL_BEST_ONLINE_RATING_MONTH = 22; + + //Private Properties + private $url = ""; + + private $mode = null; + private $trackName = null; + private $authorName = null; + private $mod = null; + private $authorId = null; + private $maniaScriptType = null; + private $titlePack = null; + private $replayType = null; + private $style = null; + private $length = null; + private $lengthOperator = null; + private $priorityOrder = null; + private $secondaryOrder = null; + private $environments = null; + private $vehicles = null; + private $page = null; + private $limit = null; + private $unreleased = null; + private $mapGroup = null; + private $commentsMinLength = null; + private $customScreenshot = null; + private $minExeBuild = null; + private $envMix = null; + private $ghostBlocks = null; + private $embeddedObjects = null; + + /** @var ManiaControl $maniaControl */ + private $maniaControl = null; + + /** + * Construct map manager + * + * @param \ManiaControl\ManiaControl $maniaControl + */ + public function __construct(ManiaControl $maniaControl) { + $this->maniaControl = $maniaControl; + + + $titleId = $this->maniaControl->getServer()->titleId; + $titlePrefix = $this->maniaControl->getMapManager()->getCurrentMap()->getGame(); + + $this->url = 'http://' . $titlePrefix . '.mania-exchange.com/tracksearch2/search?api=on'; + + //Set some defaults: + //Set Min Exe Build Default for games which are not Trackmania + if ($titlePrefix !== "tm") { + $this->minExeBuild = ManiaExchangeManager::MIN_EXE_BUILD; + } + + //Set MapTypes + try { + $scriptInfos = $this->maniaControl->getClient()->getModeScriptInfo(); + $mapTypes = $scriptInfos->compatibleMapTypes; + $this->maniaScriptType = $mapTypes; + } 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; + } + + //More Defaults: + $this->limit = 100; + $this->priorityOrder = self::SEARCH_ORDER_UPDATED_NEWEST; + } + + /** + * Fetch a MapList Asynchronously + * + * @param callable $function + */ + public function fetchMapsAsync(callable $function) { + $titlePrefix = $this->maniaControl->getMapManager()->getCurrentMap()->getGame(); + + // compile search URL + $parameters = ""; + + //TODO ALl Parameters + //$url .= "&..."; //TODO + + + $this->maniaControl->getFileReader()->loadFile($this->url . $parameters, function ($mapInfo, $error) use (&$function, $titlePrefix) { + if ($error) { + trigger_error($error); + return; + } + + $mxMapList = json_decode($mapInfo); + + if (!isset($mxMapList->results)) { + trigger_error('Cannot decode searched JSON data'); + return; + } + + $mxMapList = $mxMapList->results; + + if ($mxMapList === null) { + trigger_error('Cannot decode searched JSON data'); + return; + } + + $maps = array(); + foreach ($mxMapList as $map) { + if (!empty($map)) { + array_push($maps, new MXMapInfo($titlePrefix, $map)); + } + } + + call_user_func($function, $maps); + }, AsynchronousFileReader::CONTENT_TYPE_JSON); + } + + + /** + * Get the Current Environment by String + * + * @param string $env + * @return int + */ + private function getEnvironment($env) { + switch ($env) { + case 'TMCanyon': + return 1; + case 'TMStadium': + return 2; + case 'TMValley': + return 3; + default: + return -1; + } + } + + /** + * @param int $mode + */ + public function setMode($mode) { + $this->mode = $mode; + } + + /** + * @param string $trackName + */ + public function setTrackName($trackName) { + $this->trackName = $trackName; + } + + /** + * @param string $authorName + */ + public function setAuthorName($authorName) { + $this->authorName = $authorName; + } + + /** + * @param int $authorId + */ + public function setAuthorId($authorId) { + $this->authorId = $authorId; + } + + /** + * @param string $maniaScriptType + */ + public function setManiaScriptType($maniaScriptType) { + $this->maniaScriptType = $maniaScriptType; + } + + /** + * @param string $mod + */ + public function setMod($mod) { + $this->mod = $mod; + } + + /** + * @param string $titlePack + */ + public function setTitlePack($titlePack) { + $this->titlePack = $titlePack; + } + + /** + * @param int $replayType + */ + public function setReplayType($replayType) { + $this->replayType = $replayType; + } + + /** + * @param int $length + */ + public function setLength($length) { + $this->length = $length; + } + + /** + * @param int $style + */ + public function setStyle($style) { + $this->style = $style; + } + + /** + * @param int $lengthOperator + */ + public function setLengthOperator($lengthOperator) { + $this->lengthOperator = $lengthOperator; + } + + /** + * @param int $secondaryOrder + */ + public function setSecondaryOrder($secondaryOrder) { + $this->secondaryOrder = $secondaryOrder; + } + + /** + * @param int $priorityOrder + */ + public function setPriorityOrder($priorityOrder) { + $this->priorityOrder = $priorityOrder; + } + + /** + * @param string $environments + */ + public function setEnvironments($environments) { + $this->environments = $environments; + } + + /** + * @param int $page + */ + public function setPage($page) { + $this->page = $page; + } + + /** + * @param string $vehicles + */ + public function setVehicles($vehicles) { + $this->vehicles = $vehicles; + } + + /** + * @param bool $unreleased + */ + public function setUnreleased($unreleased) { + $this->unreleased = $unreleased; + } + + /** + * @param int $mapGroup + */ + public function setMapGroup($mapGroup) { + $this->mapGroup = $mapGroup; + } + + /** + * @param int $commentsMinLength + */ + public function setCommentsMinLength($commentsMinLength) { + $this->commentsMinLength = $commentsMinLength; + } + + /** + * @param bool $customScreenshot + */ + public function setCustomScreenshot($customScreenshot) { + $this->customScreenshot = $customScreenshot; + } + + /** + * @param bool $envMix + */ + public function setEnvMix($envMix) { + $this->envMix = $envMix; + } + + /** + * @param string $minExeBuild + */ + public function setMinExeBuild($minExeBuild) { + $this->minExeBuild = $minExeBuild; + } + + /** + * @param bool $ghostBlocks + */ + public function setGhostBlocks($ghostBlocks) { + $this->ghostBlocks = $ghostBlocks; + } + + /** + * @param bool $embeddedObjects + */ + public function setEmbeddedObjects($embeddedObjects) { + $this->embeddedObjects = $embeddedObjects; + } +} \ No newline at end of file From b4fbac6b56f84caea17ff93f1f3b189b7f22ee5d Mon Sep 17 00:00:00 2001 From: kremsy Date: Wed, 21 Jan 2015 20:59:24 +0100 Subject: [PATCH 06/97] finished mapsearch class (not tested yet) --- core/ManiaExchange/ManiaExchangeMapSearch.php | 106 +++++++++++++++--- 1 file changed, 90 insertions(+), 16 deletions(-) diff --git a/core/ManiaExchange/ManiaExchangeMapSearch.php b/core/ManiaExchange/ManiaExchangeMapSearch.php index b25370e6..62698485 100644 --- a/core/ManiaExchange/ManiaExchangeMapSearch.php +++ b/core/ManiaExchange/ManiaExchangeMapSearch.php @@ -51,7 +51,8 @@ class ManiaExchangeMapSearch { const SEARCH_ORDER_SPECIAL_BEST_ONLINE_RATING_MONTH = 22; //Private Properties - private $url = ""; + private $url = ""; + private $titlePrefix = ""; private $mode = null; private $trackName = null; @@ -82,6 +83,10 @@ class ManiaExchangeMapSearch { /** @var ManiaControl $maniaControl */ private $maniaControl = null; + //TODO test class + //TODO test booleans + //TODO use class by maniaexchangemanager and mxlist + /** * Construct map manager * @@ -91,14 +96,17 @@ class ManiaExchangeMapSearch { $this->maniaControl = $maniaControl; - $titleId = $this->maniaControl->getServer()->titleId; - $titlePrefix = $this->maniaControl->getMapManager()->getCurrentMap()->getGame(); + $titleId = $this->maniaControl->getServer()->titleId; + $this->titlePrefix = $this->maniaControl->getMapManager()->getCurrentMap()->getGame(); - $this->url = 'http://' . $titlePrefix . '.mania-exchange.com/tracksearch2/search?api=on'; + $this->url = 'http://' . $this->titlePrefix . '.mania-exchange.com/tracksearch2/search?api=on'; //Set some defaults: + $this->limit = 100; + $this->priorityOrder = self::SEARCH_ORDER_UPDATED_NEWEST; + //Set Min Exe Build Default for games which are not Trackmania - if ($titlePrefix !== "tm") { + if ($this->titlePrefix !== "tm") { $this->minExeBuild = ManiaExchangeManager::MIN_EXE_BUILD; } @@ -116,10 +124,6 @@ class ManiaExchangeMapSearch { if ($envNumber > -1) { $this->environments = $envNumber; } - - //More Defaults: - $this->limit = 100; - $this->priorityOrder = self::SEARCH_ORDER_UPDATED_NEWEST; } /** @@ -128,16 +132,86 @@ class ManiaExchangeMapSearch { * @param callable $function */ public function fetchMapsAsync(callable $function) { - $titlePrefix = $this->maniaControl->getMapManager()->getCurrentMap()->getGame(); - // compile search URL $parameters = ""; - //TODO ALl Parameters - //$url .= "&..."; //TODO - + if ($this->mode) { + $parameters .= "&mode=" . $this->mode; + } + if ($this->trackName) { + $parameters .= "&trackname=" . str_replace(" ", "%20", $this->trackName); //TODO test without the str_replace (URLENCODE) + } + if ($this->authorName) { + $parameters .= "&author=" . $this->authorName; + } + if ($this->mod) { + $parameters .= "&mod=" . $this->mod; + } + if ($this->authorId) { + $parameters .= "&authorid= " . $this->authorId; + } + if ($this->maniaScriptType) { + $parameters .= "&mtype=" . $this->maniaScriptType; + } + if ($this->titlePack) { + $parameters .= "&tpack=" . $this->titlePack; + } + if ($this->replayType) { + $parameters .= "&rytpe=" . $this->replayType; + } + if ($this->style) { + $parameters .= "&style=" . $this->style; + } + if ($this->length) { + $parameters .= "&length=" . $this->length; + } + if ($this->lengthOperator) { + $parameters .= "&lengthop=" . $this->lengthOperator; + } + if ($this->priorityOrder) { + $parameters .= "&priord=" . $this->priorityOrder; + } + if ($this->secondaryOrder) { + $parameters .= "&secord=" . $this->secondaryOrder; + } + if ($this->environments) { + $parameters .= "&environemtns=" . $this->environments; + } + if ($this->vehicles) { + $parameters .= "&vehicles=" . $this->vehicles; + } + if ($this->page) { + $parameters .= "&page=" . $this->page; + } + if ($this->limit) { + $parameters .= "&limit=" . $this->limit; + } + if (isset($this->unreleased)) { + $parameters .= "&unreleased=" . $this->unreleased; + } + if ($this->mapGroup) { + $parameters .= "&mapgroup=" . $this->mapGroup; + } + if ($this->commentsMinLength) { + $parameters .= "&commentsminlength=" . $this->commentsMinLength; + } + if (isset($this->customScreenshot)) { + $parameters .= "&customscreenshot=" . $this->customScreenshot; + } + if ($this->minExeBuild) { + $parameters .= "&minexebuild=" . $this->minExeBuild; + } + if (isset($this->envMix)) { + $parameters .= "&envmix=" . (int) $this->envMix; + } + if (isset($this->ghostBlocks)) { + $parameters .= "&ghostblocks=" . (int) $this->ghostBlocks; + } + if (isset($this->embeddedObjects)) { + $parameters .= "&embeddedObjects" . (int) $this->embeddedObjects; + } - $this->maniaControl->getFileReader()->loadFile($this->url . $parameters, function ($mapInfo, $error) use (&$function, $titlePrefix) { + $this->maniaControl->getFileReader()->loadFile($this->url . $parameters, function ($mapInfo, $error) use (&$function) { if ($error) { trigger_error($error); return; @@ -160,7 +234,7 @@ class ManiaExchangeMapSearch { $maps = array(); foreach ($mxMapList as $map) { if (!empty($map)) { - array_push($maps, new MXMapInfo($titlePrefix, $map)); + array_push($maps, new MXMapInfo($this->titlePrefix, $map)); } } From 67208624e5d8436676c00efb610daf3fee1d6208 Mon Sep 17 00:00:00 2001 From: kremsy Date: Wed, 21 Jan 2015 21:02:48 +0100 Subject: [PATCH 07/97] fixed typo --- core/ManiaExchange/ManiaExchangeMapSearch.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/ManiaExchange/ManiaExchangeMapSearch.php b/core/ManiaExchange/ManiaExchangeMapSearch.php index 62698485..49969aff 100644 --- a/core/ManiaExchange/ManiaExchangeMapSearch.php +++ b/core/ManiaExchange/ManiaExchangeMapSearch.php @@ -208,7 +208,7 @@ class ManiaExchangeMapSearch { $parameters .= "&ghostblocks=" . (int) $this->ghostBlocks; } if (isset($this->embeddedObjects)) { - $parameters .= "&embeddedObjects" . (int) $this->embeddedObjects; + $parameters .= "&embeddedobjects=" . (int) $this->embeddedObjects; } $this->maniaControl->getFileReader()->loadFile($this->url . $parameters, function ($mapInfo, $error) use (&$function) { From eeac91bd22a6dd684cf76bc4c4c9fa5d0d9d1012 Mon Sep 17 00:00:00 2001 From: kremsy Date: Wed, 21 Jan 2015 21:26:48 +0100 Subject: [PATCH 08/97] final tested version of maniaexchange map search --- core/ManiaExchange/ManiaExchangeManager.php | 78 ++++--------------- core/ManiaExchange/ManiaExchangeMapSearch.php | 46 ++++++----- 2 files changed, 39 insertions(+), 85 deletions(-) diff --git a/core/ManiaExchange/ManiaExchangeManager.php b/core/ManiaExchange/ManiaExchangeManager.php index 8dbed022..d7fc5509 100644 --- a/core/ManiaExchange/ManiaExchangeManager.php +++ b/core/ManiaExchange/ManiaExchangeManager.php @@ -272,7 +272,7 @@ class ManiaExchangeManager { * @deprecated * @see \ManiaControl\ManiaExchange\ManiaExchangeManager::fetchMapsAsync() */ - public function getMapsAsync(callable $function, $name = '', $author = '', $env = '', $maxMapsReturned = 100, $searchOrder = self::SEARCH_ORDER_UPDATED_NEWEST) { + public function getMapsAsync(callable $function, $name = '', $author = '', $env = '', $maxMapsReturned = 100, $searchOrder = ManiaExchangeMapSearch::SEARCH_ORDER_UPDATED_NEWEST) { $this->fetchMapsAsync($function, $name, $author, $env, $maxMapsReturned, $searchOrder); return true; } @@ -286,74 +286,22 @@ class ManiaExchangeManager { * @param string $env * @param int $maxMapsReturned * @param int $searchOrder + * + * @deprecated + * @see \ManiaControl\ManiaExchange\ManiaExchangeMapSearch */ - public function fetchMapsAsync(callable $function, $name = '', $author = '', $env = '', $maxMapsReturned = 100, $searchOrder = self::SEARCH_ORDER_UPDATED_NEWEST) { - //TODO provide additional parameters as array, generally new structure - // TODO: remove $env because it's not really used? + public function fetchMapsAsync(callable $function, $name = '', $author = '', $env = '', $maxMapsReturned = 100, $sortOrder = ManiaExchangeMapSearch::SEARCH_ORDER_UPDATED_NEWEST) { + $mapSearch = new ManiaExchangeMapSearch($this->maniaControl); + $mapSearch->setMapName($name); + $mapSearch->setAuthorName($author); + $mapSearch->setMapLimit($maxMapsReturned); + $mapSearch->setPrioritySortOrder($sortOrder); - // Get Title Id - $titleId = $this->maniaControl->getServer()->titleId; - $titlePrefix = $this->maniaControl->getMapManager()->getCurrentMap()->getGame(); - - // compile search URL - $url = 'http://' . $titlePrefix . '.mania-exchange.com/tracksearch2/search?api=on'; - - $game = explode('@', $titleId); - $envNumber = $this->getEnvironment($game[0]); - if ($env || $envNumber > -1) { - $url .= '&environments=' . $envNumber; - } - if ($name) { - $url .= '&trackname=' . str_replace(" ", "%20", $name); - } - if ($author) { - $url .= '&author=' . $author; + if($env){ + $mapSearch->setEnvironments($env); } - $url .= '&priord=' . $searchOrder; - $url .= '&limit=' . $maxMapsReturned; - - if ($titlePrefix !== "tm") { - $url .= '&minexebuild=' . self::MIN_EXE_BUILD; - } - - // Get MapTypes - try { - $scriptInfos = $this->maniaControl->getClient()->getModeScriptInfo(); - $mapTypes = $scriptInfos->compatibleMapTypes; - $url .= '&mtype=' . $mapTypes; - } catch (GameModeException $e) { - } - - $this->maniaControl->getFileReader()->loadFile($url, function ($mapInfo, $error) use (&$function, $titlePrefix) { - if ($error) { - trigger_error($error); - return; - } - - $mxMapList = json_decode($mapInfo); - - if (!isset($mxMapList->results)) { - trigger_error('Cannot decode searched JSON data'); - return; - } - - $mxMapList = $mxMapList->results; - - if ($mxMapList === null) { - trigger_error('Cannot decode searched JSON data'); - return; - } - - $maps = array(); - foreach ($mxMapList as $map) { - if (!empty($map)) { - array_push($maps, new MXMapInfo($titlePrefix, $map)); - } - } - - call_user_func($function, $maps); - }, AsynchronousFileReader::CONTENT_TYPE_JSON); + $mapSearch->fetchMapsAsync($function); } /** diff --git a/core/ManiaExchange/ManiaExchangeMapSearch.php b/core/ManiaExchange/ManiaExchangeMapSearch.php index 49969aff..b991397e 100644 --- a/core/ManiaExchange/ManiaExchangeMapSearch.php +++ b/core/ManiaExchange/ManiaExchangeMapSearch.php @@ -55,7 +55,7 @@ class ManiaExchangeMapSearch { private $titlePrefix = ""; private $mode = null; - private $trackName = null; + private $mapName = null; private $authorName = null; private $mod = null; private $authorId = null; @@ -70,7 +70,7 @@ class ManiaExchangeMapSearch { private $environments = null; private $vehicles = null; private $page = null; - private $limit = null; + private $mapLimit = null; private $unreleased = null; private $mapGroup = null; private $commentsMinLength = null; @@ -83,9 +83,7 @@ class ManiaExchangeMapSearch { /** @var ManiaControl $maniaControl */ private $maniaControl = null; - //TODO test class - //TODO test booleans - //TODO use class by maniaexchangemanager and mxlist + //TODO use class by mxlist /** * Construct map manager @@ -138,23 +136,23 @@ class ManiaExchangeMapSearch { if ($this->mode) { $parameters .= "&mode=" . $this->mode; } - if ($this->trackName) { - $parameters .= "&trackname=" . str_replace(" ", "%20", $this->trackName); //TODO test without the str_replace (URLENCODE) + if ($this->mapName) { + $parameters .= "&trackname=" . urlencode($this->mapName); } if ($this->authorName) { - $parameters .= "&author=" . $this->authorName; + $parameters .= "&author=" . urlencode($this->authorName); } if ($this->mod) { - $parameters .= "&mod=" . $this->mod; + $parameters .= "&mod=" . urlencode($this->mod); } if ($this->authorId) { $parameters .= "&authorid= " . $this->authorId; } if ($this->maniaScriptType) { - $parameters .= "&mtype=" . $this->maniaScriptType; + $parameters .= "&mtype=" . urlencode($this->maniaScriptType); } if ($this->titlePack) { - $parameters .= "&tpack=" . $this->titlePack; + $parameters .= "&tpack=" . urlencode($this->titlePack); } if ($this->replayType) { $parameters .= "&rytpe=" . $this->replayType; @@ -183,11 +181,11 @@ class ManiaExchangeMapSearch { if ($this->page) { $parameters .= "&page=" . $this->page; } - if ($this->limit) { - $parameters .= "&limit=" . $this->limit; + if ($this->mapLimit) { + $parameters .= "&limit=" . $this->mapLimit; } if (isset($this->unreleased)) { - $parameters .= "&unreleased=" . $this->unreleased; + $parameters .= "&unreleased=" . (int) $this->unreleased; } if ($this->mapGroup) { $parameters .= "&mapgroup=" . $this->mapGroup; @@ -199,7 +197,7 @@ class ManiaExchangeMapSearch { $parameters .= "&customscreenshot=" . $this->customScreenshot; } if ($this->minExeBuild) { - $parameters .= "&minexebuild=" . $this->minExeBuild; + $parameters .= "&minexebuild=" . urlencode($this->minExeBuild); } if (isset($this->envMix)) { $parameters .= "&envmix=" . (int) $this->envMix; @@ -211,6 +209,7 @@ class ManiaExchangeMapSearch { $parameters .= "&embeddedobjects=" . (int) $this->embeddedObjects; } + var_dump($this->url . $parameters); $this->maniaControl->getFileReader()->loadFile($this->url . $parameters, function ($mapInfo, $error) use (&$function) { if ($error) { trigger_error($error); @@ -270,10 +269,10 @@ class ManiaExchangeMapSearch { } /** - * @param string $trackName + * @param string $mapName */ - public function setTrackName($trackName) { - $this->trackName = $trackName; + public function setMapName($mapName) { + $this->mapName = $mapName; } /** @@ -342,14 +341,14 @@ class ManiaExchangeMapSearch { /** * @param int $secondaryOrder */ - public function setSecondaryOrder($secondaryOrder) { + public function setSecondarySortOrder($secondaryOrder) { $this->secondaryOrder = $secondaryOrder; } /** * @param int $priorityOrder */ - public function setPriorityOrder($priorityOrder) { + public function setPrioritySortOrder($priorityOrder) { $this->priorityOrder = $priorityOrder; } @@ -429,4 +428,11 @@ class ManiaExchangeMapSearch { public function setEmbeddedObjects($embeddedObjects) { $this->embeddedObjects = $embeddedObjects; } + + /** + * @param null $mapLimit + */ + public function setMapLimit($mapLimit) { + $this->mapLimit = $mapLimit; + } } \ No newline at end of file From efa9c275c9feabc6669d7feb7cc948d488eae69c Mon Sep 17 00:00:00 2001 From: kremsy Date: Wed, 21 Jan 2015 21:27:40 +0100 Subject: [PATCH 09/97] removed debug var_dump --- core/ManiaExchange/ManiaExchangeMapSearch.php | 1 - 1 file changed, 1 deletion(-) diff --git a/core/ManiaExchange/ManiaExchangeMapSearch.php b/core/ManiaExchange/ManiaExchangeMapSearch.php index b991397e..ec6a4d39 100644 --- a/core/ManiaExchange/ManiaExchangeMapSearch.php +++ b/core/ManiaExchange/ManiaExchangeMapSearch.php @@ -209,7 +209,6 @@ class ManiaExchangeMapSearch { $parameters .= "&embeddedobjects=" . (int) $this->embeddedObjects; } - var_dump($this->url . $parameters); $this->maniaControl->getFileReader()->loadFile($this->url . $parameters, function ($mapInfo, $error) use (&$function) { if ($error) { trigger_error($error); From e4100ea045224b5289017db99d75166ec25c9f64 Mon Sep 17 00:00:00 2001 From: kremsy Date: Fri, 23 Jan 2015 14:55:10 +0100 Subject: [PATCH 10/97] increased mc version due recent changes (new beta + nightly release) --- core/ManiaControl.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/ManiaControl.php b/core/ManiaControl.php index 086112a3..2eadd20a 100644 --- a/core/ManiaControl.php +++ b/core/ManiaControl.php @@ -42,7 +42,7 @@ class ManiaControl implements CallbackListener, CommandListener, TimerListener { /* * Constants */ - const VERSION = '0.155'; + const VERSION = '0.156'; const API_VERSION = '2013-04-16'; const MIN_DEDIVERSION = '2014-04-02_18_00'; const SCRIPT_TIMEOUT = 10; From c583d52e309c800690eecb606705f7cc12c763a7 Mon Sep 17 00:00:00 2001 From: kremsy Date: Fri, 23 Jan 2015 19:05:07 +0100 Subject: [PATCH 11/97] added endroundstop --- core/Callbacks/Callbacks.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/core/Callbacks/Callbacks.php b/core/Callbacks/Callbacks.php index e450879a..79684657 100644 --- a/core/Callbacks/Callbacks.php +++ b/core/Callbacks/Callbacks.php @@ -49,6 +49,8 @@ interface Callbacks { const ENDTURNSTOP = 'Callbacks.EndTurnStop'; /** EndRound Callback: RoundNumber */ const ENDROUND = 'Callbacks.EndRound'; + /** EndRound Callback: RoundNumber */ + const ENDROUNDSTOP = 'Callbacks.EndRoundStop'; /** EndSubmatch Callback: SubmatchNumber */ const ENDSUBMATCH = 'Callbacks.EndSubmatch'; /** EndMap Callback: Map */ From ea44fc5dc25f73723ba559fc6438c10ebfccbe7d Mon Sep 17 00:00:00 2001 From: kremsy Date: Fri, 23 Jan 2015 19:17:02 +0100 Subject: [PATCH 12/97] added endroundstop --- core/Callbacks/LibXmlRpcCallbacks.php | 3 +++ 1 file changed, 3 insertions(+) diff --git a/core/Callbacks/LibXmlRpcCallbacks.php b/core/Callbacks/LibXmlRpcCallbacks.php index 8b306580..5f11bc1e 100644 --- a/core/Callbacks/LibXmlRpcCallbacks.php +++ b/core/Callbacks/LibXmlRpcCallbacks.php @@ -82,6 +82,9 @@ class LibXmlRpcCallbacks implements CallbackListener { case 'LibXmlRpc_EndRound': $this->maniaControl->getCallbackManager()->triggerCallback(Callbacks::ENDROUND, $data[0]); break; + case 'LibXmlRpc_EndRoundStop': + $this->maniaControl->getCallbackManager()->triggerCallback(Callbacks::ENDROUND, $data[0]); + break; case 'LibXmlRpc_EndSubmatch': $this->maniaControl->getCallbackManager()->triggerCallback(Callbacks::ENDSUBMATCH, $data[0]); break; From 8c54b3d6fc142e7f26195b6675df097f3f754157 Mon Sep 17 00:00:00 2001 From: kremsy Date: Fri, 23 Jan 2015 19:18:29 +0100 Subject: [PATCH 13/97] endroundstop --- core/Callbacks/LibXmlRpcCallbacks.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/Callbacks/LibXmlRpcCallbacks.php b/core/Callbacks/LibXmlRpcCallbacks.php index 5f11bc1e..b58c2de0 100644 --- a/core/Callbacks/LibXmlRpcCallbacks.php +++ b/core/Callbacks/LibXmlRpcCallbacks.php @@ -83,7 +83,7 @@ class LibXmlRpcCallbacks implements CallbackListener { $this->maniaControl->getCallbackManager()->triggerCallback(Callbacks::ENDROUND, $data[0]); break; case 'LibXmlRpc_EndRoundStop': - $this->maniaControl->getCallbackManager()->triggerCallback(Callbacks::ENDROUND, $data[0]); + $this->maniaControl->getCallbackManager()->triggerCallback(Callbacks::ENDROUNDSTOP, $data[0]); break; case 'LibXmlRpc_EndSubmatch': $this->maniaControl->getCallbackManager()->triggerCallback(Callbacks::ENDSUBMATCH, $data[0]); From fd7770d16799c87a2ac03471c682bf874b019db9 Mon Sep 17 00:00:00 2001 From: kremsy Date: Sat, 24 Jan 2015 23:29:39 +0100 Subject: [PATCH 14/97] new exception found ;) --- libs/Maniaplanet/DedicatedServer/Xmlrpc/FaultException.php | 1 + 1 file changed, 1 insertion(+) diff --git a/libs/Maniaplanet/DedicatedServer/Xmlrpc/FaultException.php b/libs/Maniaplanet/DedicatedServer/Xmlrpc/FaultException.php index 785eea78..c3e37d7b 100755 --- a/libs/Maniaplanet/DedicatedServer/Xmlrpc/FaultException.php +++ b/libs/Maniaplanet/DedicatedServer/Xmlrpc/FaultException.php @@ -72,6 +72,7 @@ class FaultException extends Exception case 'You cannot change the max spectators count: AllowSpectatorRelays is activated.': case 'There are too many players': case 'There are too many spectators': + case 'Unknown hideserver value': return new ServerOptionsException($faultString, $faultCode); case 'New mode unknown.': case 'You need to stop the server to change to/from script mode.': From ef90574ca09f8077aee8210a1951653e48aed21c Mon Sep 17 00:00:00 2001 From: kremsy Date: Sun, 1 Feb 2015 11:34:51 +0100 Subject: [PATCH 15/97] small fixes/cleanups --- core/ManiaExchange/ManiaExchangeList.php | 10 +++++++--- core/ManiaExchange/ManiaExchangeManager.php | 2 +- core/Maps/MapList.php | 2 +- 3 files changed, 9 insertions(+), 5 deletions(-) diff --git a/core/ManiaExchange/ManiaExchangeList.php b/core/ManiaExchange/ManiaExchangeList.php index 24c8f71c..9d061dd4 100644 --- a/core/ManiaExchange/ManiaExchangeList.php +++ b/core/ManiaExchange/ManiaExchangeList.php @@ -130,14 +130,18 @@ class ManiaExchangeList implements CallbackListener, ManialinkPageAnswerListener } } - // search for matching maps - $this->maniaControl->getMapManager()->getMXManager()->fetchMapsAsync(function (array $maps) use (&$player) { + //Search the Maps + $mxSearch = new ManiaExchangeMapSearch($this->maniaControl); + $mxSearch->setAuthorName($author); + $mxSearch->setEnvironments($environment); + $mxSearch->setMapName($searchString); + $mxSearch->fetchMapsAsync(function (array $maps) use (&$player) { if (!$maps) { $this->maniaControl->getChat()->sendError('No maps found, or MX is down!', $player->login); return; } $this->showManiaExchangeList($maps, $player); - }, $searchString, $author, $environment); + }); } /** diff --git a/core/ManiaExchange/ManiaExchangeManager.php b/core/ManiaExchange/ManiaExchangeManager.php index d7fc5509..f220ab3f 100644 --- a/core/ManiaExchange/ManiaExchangeManager.php +++ b/core/ManiaExchange/ManiaExchangeManager.php @@ -270,7 +270,7 @@ class ManiaExchangeManager { /** * @deprecated - * @see \ManiaControl\ManiaExchange\ManiaExchangeManager::fetchMapsAsync() + * @see \ManiaControl\ManiaExchange\ManiaExchangeMapSearch */ public function getMapsAsync(callable $function, $name = '', $author = '', $env = '', $maxMapsReturned = 100, $searchOrder = ManiaExchangeMapSearch::SEARCH_ORDER_UPDATED_NEWEST) { $this->fetchMapsAsync($function, $name, $author, $env, $maxMapsReturned, $searchOrder); diff --git a/core/Maps/MapList.php b/core/Maps/MapList.php index 8246d009..728d74f5 100644 --- a/core/Maps/MapList.php +++ b/core/Maps/MapList.php @@ -454,7 +454,7 @@ class MapList implements ManialinkPageAnswerListener, CallbackListener { $votes = $karmaPlugin->getMapVotes($map); } - if (is_numeric($karma)) { + if (is_numeric($karma) && $votes['count'] > 0) { if ($this->maniaControl->getSettingManager()->getSettingValue($karmaPlugin, $karmaPlugin::SETTING_NEWKARMA) ) { $karmaText = ' ' . round($karma * 100.) . '% (' . $votes['count'] . ')'; From 723ed19e08e1a96eca32e995ac7e21588f73a7bf Mon Sep 17 00:00:00 2001 From: kremsy Date: Sun, 1 Feb 2015 11:41:17 +0100 Subject: [PATCH 16/97] z fix in advanced playerlist --- core/Players/PlayerList.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/core/Players/PlayerList.php b/core/Players/PlayerList.php index c77df989..7daf363b 100644 --- a/core/Players/PlayerList.php +++ b/core/Players/PlayerList.php @@ -467,14 +467,14 @@ class PlayerList implements ManialinkPageAnswerListener, CallbackListener, Timer $backgroundQuad->setSize($width, $height); $backgroundQuad->setImage('https://dl.dropboxusercontent.com/u/105352981/Stuff/CAM%20SM%20BORDER%20PNG.png'); //TODO just a test //$backgroundQuad->setStyles($quadStyle, $quadSubstyle); - $backgroundQuad->setZ(0.2); + $backgroundQuad->setZ(-0.3); // Background Quad $backgroundQuad = new Quad(); $frame->add($backgroundQuad); $backgroundQuad->setSize($width - 2, $height - 2); $backgroundQuad->setStyles($quadStyle, $quadSubstyle); - $backgroundQuad->setZ(0.1); + $backgroundQuad->setZ(-0.4); // Show headline $label = new Label_Text(); From 535f3058ccc4c11f6dba2877cd84a40ab34fe424 Mon Sep 17 00:00:00 2001 From: kremsy Date: Sun, 1 Feb 2015 12:12:22 +0100 Subject: [PATCH 17/97] exception catch --- plugins/MCTeam/ChatMessagePlugin.php | 3 +++ 1 file changed, 3 insertions(+) diff --git a/plugins/MCTeam/ChatMessagePlugin.php b/plugins/MCTeam/ChatMessagePlugin.php index f96d13cd..414b8432 100644 --- a/plugins/MCTeam/ChatMessagePlugin.php +++ b/plugins/MCTeam/ChatMessagePlugin.php @@ -7,6 +7,7 @@ use ManiaControl\ManiaControl; use ManiaControl\Players\Player; use ManiaControl\Plugins\Plugin; use Maniaplanet\DedicatedServer\Xmlrpc\PlayerStateException; +use Maniaplanet\DedicatedServer\Xmlrpc\ServerOptionsException; use Maniaplanet\DedicatedServer\Xmlrpc\UnknownPlayerException; /** @@ -407,6 +408,8 @@ class ChatMessagePlugin implements CommandListener, Plugin { } catch (UnknownPlayerException $exception) { $this->maniaControl->getChat()->sendException($exception, $player); } catch (PlayerStateException $exception) { + } catch (ServerOptionsException $exception) { + //too many spectators } } From a95f93c4a86e48ba274a293d450fbbed3b88ccb2 Mon Sep 17 00:00:00 2001 From: kremsy Date: Wed, 4 Feb 2015 23:16:52 +0100 Subject: [PATCH 18/97] action menu fix --- core/Admin/ActionsMenu.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/Admin/ActionsMenu.php b/core/Admin/ActionsMenu.php index 78aa78b9..c5afda03 100644 --- a/core/Admin/ActionsMenu.php +++ b/core/Admin/ActionsMenu.php @@ -290,7 +290,7 @@ class ActionsMenu implements CallbackListener, ManialinkPageAnswerListener { unset($this->playerMenuItems[$order]); } } else { - if (isset($this->playerMenuItems[$order])) { + if (isset($this->adminMenuItems[$order])) { unset($this->adminMenuItems[$order]); } } From 58072861c34cbdeeb8f410091c8be7b43d7c1226 Mon Sep 17 00:00:00 2001 From: kremsy Date: Thu, 19 Feb 2015 11:24:37 +0100 Subject: [PATCH 19/97] Temporary workaround for Trackmania Manialink bug --- core/Manialinks/StyleManager.php | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/core/Manialinks/StyleManager.php b/core/Manialinks/StyleManager.php index 74144cd9..7409067a 100644 --- a/core/Manialinks/StyleManager.php +++ b/core/Manialinks/StyleManager.php @@ -161,6 +161,13 @@ class StyleManager { $frame = new Frame(); $frame->setSize($width, $height)->setZ(45); //TODO place before scoreboards + //TODO remove: (just temporary fix for tm bug) + if ($this->maniaControl->getMapManager()->getCurrentMap()->getGame() === 'tm' + ) { + $frame->setSize($width, $height)->setZ(30); + } + + // Background Quad $backgroundQuad = new Quad(); $frame->add($backgroundQuad); From cee9039c0becfb8ee3ba4e17cc207f0084816be5 Mon Sep 17 00:00:00 2001 From: kremsy Date: Tue, 24 Feb 2015 10:21:27 +0100 Subject: [PATCH 20/97] added zlib to required extensions --- .idea/codeStyleSettings.xml | 4 ++-- README.md | 4 ++-- core/Utils/SystemUtil.php | 10 ++++++++++ 3 files changed, 14 insertions(+), 4 deletions(-) diff --git a/.idea/codeStyleSettings.xml b/.idea/codeStyleSettings.xml index ba7af51e..22cd6899 100644 --- a/.idea/codeStyleSettings.xml +++ b/.idea/codeStyleSettings.xml @@ -54,6 +54,7 @@