From eca7ec86ae2f42d354a50f93529cbb0978a5c593 Mon Sep 17 00:00:00 2001 From: kremsy Date: Sun, 12 Jan 2014 22:24:30 +0100 Subject: [PATCH] bugfix --- .../core/Configurators/ServerSettings.php | 16 ++++++++++------ .../ManiaExchange/ManiaExchangeInfoSearcher.php | 8 +++----- 2 files changed, 13 insertions(+), 11 deletions(-) diff --git a/application/core/Configurators/ServerSettings.php b/application/core/Configurators/ServerSettings.php index 5355d1ae..e186f7f2 100644 --- a/application/core/Configurators/ServerSettings.php +++ b/application/core/Configurators/ServerSettings.php @@ -90,9 +90,10 @@ class ServerSettings implements ConfiguratorMenu, CallbackListener { * @return bool */ public function loadSettingsFromDatabase() { - $mysqli = $this->maniaControl->database->mysqli; - $query = "SELECT * FROM `" . self::TABLE_SERVER_SETTINGS . "`;"; - $result = $mysqli->query($query); + $serverId = $this->maniaControl->server->index; + $mysqli = $this->maniaControl->database->mysqli; + $query = "SELECT * FROM `" . self::TABLE_SERVER_SETTINGS . "` WHERE serverIndex = " . $serverId . ";"; + $result = $mysqli->query($query); if($mysqli->error) { trigger_error($mysqli->error); return false; @@ -109,8 +110,9 @@ class ServerSettings implements ConfiguratorMenu, CallbackListener { settype($loadedSettings[$row->settingName], gettype($serverSettings[$row->settingName])); } $result->close(); - if(!$loadedSettings) + if(!$loadedSettings) { return true; + } $success = $this->maniaControl->client->query('SetServerOptions', $loadedSettings); if(!$success) { @@ -308,8 +310,9 @@ class ServerSettings implements ConfiguratorMenu, CallbackListener { public function handleManialinkPageAnswer(array $callback) { $actionId = $callback[1][2]; $boolSetting = (strpos($actionId, self::ACTION_SETTING_BOOL) === 0); - if(!$boolSetting) + if(!$boolSetting) { return; + } $login = $callback[1][1]; $player = $this->maniaControl->playerManager->getPlayer($login); @@ -326,8 +329,9 @@ class ServerSettings implements ConfiguratorMenu, CallbackListener { * @return bool */ private function applyNewScriptSettings(array $newSettings, Player $player) { - if(!$newSettings) + if(!$newSettings) { return true; + } $success = $this->maniaControl->client->query('SetServerOptions', $newSettings); if(!$success) { $this->maniaControl->chat->sendError('Error occurred: ' . $this->maniaControl->getClientErrorText(), $player->login); diff --git a/application/core/ManiaExchange/ManiaExchangeInfoSearcher.php b/application/core/ManiaExchange/ManiaExchangeInfoSearcher.php index b4de0f56..92b3e4de 100644 --- a/application/core/ManiaExchange/ManiaExchangeInfoSearcher.php +++ b/application/core/ManiaExchange/ManiaExchangeInfoSearcher.php @@ -30,9 +30,8 @@ class ManiaExchangeInfoSearcher { //TODO rename to ManiaExchangeManager const SEARCH_ORDER_DIFFICULTY_HARDEST = 13; const SEARCH_ORDER_LENGHT_SHORTEST = 14; const SEARCH_ORDER_LENGHT_LONGEST = 15; - const MAPS_PER_MX_FETCH = 10; + const MAPS_PER_MX_FETCH = 50; - const MX_CHAR_LIMIT = 250; /** * Private Propertieswc */ @@ -132,11 +131,10 @@ class ManiaExchangeInfoSearcher { //TODO rename to ManiaExchangeManager $id++; //If Max Maplimit is reached, or string gets too long send the request - if(($id % self::MAPS_PER_MX_FETCH == 0) || ((strlen($mapIdString) + strlen($appendString)) > self::MX_CHAR_LIMIT)) { + if($id % self::MAPS_PER_MX_FETCH == 0) { $maps = $this->getMaplistByMixedUidIdString($mapIdString); $this->updateMapObjectsWithManiaExchangeIds($maps); $mapIdString = ''; - $id = 1; } $mapIdString .= $appendString; @@ -157,7 +155,7 @@ class ManiaExchangeInfoSearcher { //TODO rename to ManiaExchangeManager $titlePrefix = strtolower(substr($titleId, 0, 2)); // compile search URL - $url = 'http://api.mania-exchange.com/' . $titlePrefix . '/maps/' . $string; + $url = 'http://api.mania-exchange.com/' . $titlePrefix . '/maps/?ids=' . $string; // $mapInfo = FileUtil::loadFile($url, "application/json"); //TODO use mc fileutil $mapInfo = $this->get_file($url);