diff --git a/application/core/Configurators/ScriptSettings.php b/application/core/Configurators/ScriptSettings.php index c488d3fd..b1e1d7b5 100644 --- a/application/core/Configurators/ScriptSettings.php +++ b/application/core/Configurators/ScriptSettings.php @@ -113,15 +113,6 @@ class ScriptSettings implements ConfiguratorMenu, CallbackListener { return false; } - //TODO check error on not script modes, maybe exception happen, or dunno what, there is no faultString property? - /*if (isset($scriptSettings['faultString'])) { - if ($scriptSettings['faultString'] == 'Not in script mode.') { - return false; - } - trigger_error('Error occured: ' . $scriptSettings['faultString']); - return false; - }*/ - $mysqli = $this->maniaControl->database->mysqli; $serverId = $this->maniaControl->server->index; $query = "SELECT * FROM `" . self::TABLE_SCRIPT_SETTINGS . "` WHERE serverIndex = " . $serverId . ";"; @@ -167,21 +158,23 @@ class ScriptSettings implements ConfiguratorMenu, CallbackListener { $pagesId = 'ScriptSettingsPages'; $frame = new Frame(); - $scriptInfo = $this->maniaControl->client->getModeScriptInfo(); - - //TODO check error on not script modes, maybe exception happen, or dunno what, there is no faultString property? - /*if(isset($scriptInfo['faultCode'])) { - // Not in script mode - $label = new Label(); - $frame->add($label); - $label->setText($scriptInfo['faultString']); - return $frame; - } - */ + try { + $scriptInfo = $this->maniaControl->client->getModeScriptInfo(); + } catch(\Exception $e) { + // Not in script mode + $label = new Label(); + $frame->add($label); + $label->setText($e->getMessage()); + return $frame; + } $scriptParams = $scriptInfo->paramDescs; - $scriptSettings = $this->maniaControl->client->getModeScriptSettings(); + try { + $scriptSettings = $this->maniaControl->client->getModeScriptSettings(); + } catch(\Exception $e) { + //do nothing + } // Config $pagerSize = 9.; @@ -308,7 +301,11 @@ class ScriptSettings implements ConfiguratorMenu, CallbackListener { return; } - $scriptSettings = $this->maniaControl->client->getModeScriptSettings(); + try { + $scriptSettings = $this->maniaControl->client->getModeScriptSettings(); + } catch(\Exception $e) { + return; + } $prefixLength = strlen(self::ACTION_PREFIX_SETTING); @@ -370,7 +367,12 @@ class ScriptSettings implements ConfiguratorMenu, CallbackListener { * @param $setting */ public function toggleBooleanSetting($setting, Player $player) { - $scriptSettings = $this->maniaControl->client->getModeScriptSettings(); + try { + $scriptSettings = $this->maniaControl->client->getModeScriptSettings(); + } catch(\Exception $e) { + return; + } + if (!isset($scriptSettings[$setting])) { var_dump('no setting ' . $setting); return; diff --git a/application/core/ManiaExchange/ManiaExchangeManager.php b/application/core/ManiaExchange/ManiaExchangeManager.php index 30c54baf..7bc41bcf 100644 --- a/application/core/ManiaExchange/ManiaExchangeManager.php +++ b/application/core/ManiaExchange/ManiaExchangeManager.php @@ -264,11 +264,6 @@ class ManiaExchangeManager { $titleId = $this->maniaControl->server->titleId; $titlePrefix = strtolower(substr($titleId, 0, 2)); - // Get MapTypes - $scriptInfos = $this->maniaControl->client->getModeScriptInfo(); - - $mapTypes = $scriptInfos->compatibleMapTypes; - // compile search URL $url = 'http://' . $titlePrefix . '.mania-exchange.com/tracksearch?api=on'; @@ -284,8 +279,15 @@ class ManiaExchangeManager { $url .= '&priord=' . $searchOrder; $url .= '&limit=' . $maxMapsReturned; - $url .= '&mtype=' . $mapTypes; + // Get MapTypes + try { + $scriptInfos = $this->maniaControl->client->getModeScriptInfo(); + $mapTypes = $scriptInfos->compatibleMapTypes; + $url .= '&mtype=' . $mapTypes; + } catch(\Exception $e) { + //dont append map tpye + } $fileFunc = function ($mapInfo, $error) use (&$function, $titlePrefix) { if ($error) { diff --git a/application/core/Server/ServerCommands.php b/application/core/Server/ServerCommands.php index a15d53d9..bfa99702 100644 --- a/application/core/Server/ServerCommands.php +++ b/application/core/Server/ServerCommands.php @@ -81,24 +81,6 @@ class ServerCommands implements CallbackListener, CommandListener, ManialinkPage $this->maniaControl->authenticationManager->definePermissionLevel(self::SETTING_PERMISSION_CANCEL_VOTE, AuthenticationManager::AUTH_LEVEL_MODERATOR); $this->maniaControl->authenticationManager->definePermissionLevel(self::SETTING_PERMISSION_HANDLE_WARMUP, AuthenticationManager::AUTH_LEVEL_MODERATOR); - //Check if Pause exists in current GameMode - $scriptInfos = $this->maniaControl->client->getModeScriptInfo(); - $pauseExists = false; - foreach($scriptInfos->commandDescs as $param) { - if ($param->name == "Command_ForceWarmUp") { - $pauseExists = true; - break; - } - } - - // Set Pause - if ($pauseExists) { - $itemQuad = new Quad_Icons128x32_1(); - $itemQuad->setSubStyle($itemQuad::SUBSTYLE_ManiaLinkSwitch); - $itemQuad->setAction(self::ACTION_SET_PAUSE); - $this->maniaControl->actionsMenu->addAdminMenuItem($itemQuad, 13, 'Pauses the current game'); - } - // Extend WarmUp $this->maniaControl->manialinkManager->registerManialinkPageAnswerListener(self::ACTION_EXTEND_WARMUP, $this, 'command_extendWarmup'); $itemQuad = new Quad_BgRaceScore2(); @@ -119,6 +101,28 @@ class ServerCommands implements CallbackListener, CommandListener, ManialinkPage $itemQuad->setSubStyle($itemQuad::SUBSTYLE_ArrowRed); $itemQuad->setAction(self::ACTION_CANCEL_VOTE); $this->maniaControl->actionsMenu->addMenuItem($itemQuad, false, 30, 'Cancel Vote'); + + //Check if Pause exists in current GameMode + try { + $scriptInfos = $this->maniaControl->client->getModeScriptInfo(); + } catch(\Exception $e) { + return; + } + $pauseExists = false; + foreach($scriptInfos->commandDescs as $param) { + if ($param->name == "Command_ForceWarmUp") { + $pauseExists = true; + break; + } + } + + // Set Pause + if ($pauseExists) { + $itemQuad = new Quad_Icons128x32_1(); + $itemQuad->setSubStyle($itemQuad::SUBSTYLE_ManiaLinkSwitch); + $itemQuad->setAction(self::ACTION_SET_PAUSE); + $this->maniaControl->actionsMenu->addAdminMenuItem($itemQuad, 13, 'Pauses the current game'); + } } diff --git a/application/plugins/CustomVotes.php b/application/plugins/CustomVotes.php index cb48fd66..a33d6e1e 100644 --- a/application/plugins/CustomVotes.php +++ b/application/plugins/CustomVotes.php @@ -242,22 +242,26 @@ class CustomVotesPlugin implements CommandListener, CallbackListener, ManialinkP $this->addVoteMenuItem($itemQuad, 5, 'Vote for Restart-Map'); //Check if Pause exists in current GameMode - $scriptInfos = $this->maniaControl->client->getModeScriptInfo(); + try { + $scriptInfos = $this->maniaControl->client->getModeScriptInfo(); - $pauseExists = false; - foreach($scriptInfos->commandDescs as $param) { - if ($param->name == "Command_ForceWarmUp") { - $pauseExists = true; - break; + $pauseExists = false; + foreach($scriptInfos->commandDescs as $param) { + if ($param->name == "Command_ForceWarmUp") { + $pauseExists = true; + break; + } } - } - // Menu Pause - if ($pauseExists) { - $itemQuad = new Quad_Icons128x32_1(); - $itemQuad->setSubStyle($itemQuad::SUBSTYLE_ManiaLinkSwitch); - $itemQuad->setAction(self::ACTION_START_VOTE . 'pausegame'); - $this->addVoteMenuItem($itemQuad, 10, 'Vote for a pause of Current Game'); + // Menu Pause + if ($pauseExists) { + $itemQuad = new Quad_Icons128x32_1(); + $itemQuad->setSubStyle($itemQuad::SUBSTYLE_ManiaLinkSwitch); + $itemQuad->setAction(self::ACTION_START_VOTE . 'pausegame'); + $this->addVoteMenuItem($itemQuad, 10, 'Vote for a pause of Current Game'); + } + } catch(\Exception $e) { + //do nothing } //Menu SkipMap