exception fixes

This commit is contained in:
kremsy 2014-02-13 00:26:18 +01:00 committed by Steffen Schröder
parent 071e731537
commit b1921fcc2b
4 changed files with 72 additions and 60 deletions

View File

@ -113,15 +113,6 @@ class ScriptSettings implements ConfiguratorMenu, CallbackListener {
return false; 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; $mysqli = $this->maniaControl->database->mysqli;
$serverId = $this->maniaControl->server->index; $serverId = $this->maniaControl->server->index;
$query = "SELECT * FROM `" . self::TABLE_SCRIPT_SETTINGS . "` WHERE serverIndex = " . $serverId . ";"; $query = "SELECT * FROM `" . self::TABLE_SCRIPT_SETTINGS . "` WHERE serverIndex = " . $serverId . ";";
@ -167,21 +158,23 @@ class ScriptSettings implements ConfiguratorMenu, CallbackListener {
$pagesId = 'ScriptSettingsPages'; $pagesId = 'ScriptSettingsPages';
$frame = new Frame(); $frame = new Frame();
try {
$scriptInfo = $this->maniaControl->client->getModeScriptInfo(); $scriptInfo = $this->maniaControl->client->getModeScriptInfo();
} catch(\Exception $e) {
//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 // Not in script mode
$label = new Label(); $label = new Label();
$frame->add($label); $frame->add($label);
$label->setText($scriptInfo['faultString']); $label->setText($e->getMessage());
return $frame; return $frame;
} }
*/
$scriptParams = $scriptInfo->paramDescs; $scriptParams = $scriptInfo->paramDescs;
try {
$scriptSettings = $this->maniaControl->client->getModeScriptSettings(); $scriptSettings = $this->maniaControl->client->getModeScriptSettings();
} catch(\Exception $e) {
//do nothing
}
// Config // Config
$pagerSize = 9.; $pagerSize = 9.;
@ -308,7 +301,11 @@ class ScriptSettings implements ConfiguratorMenu, CallbackListener {
return; return;
} }
try {
$scriptSettings = $this->maniaControl->client->getModeScriptSettings(); $scriptSettings = $this->maniaControl->client->getModeScriptSettings();
} catch(\Exception $e) {
return;
}
$prefixLength = strlen(self::ACTION_PREFIX_SETTING); $prefixLength = strlen(self::ACTION_PREFIX_SETTING);
@ -370,7 +367,12 @@ class ScriptSettings implements ConfiguratorMenu, CallbackListener {
* @param $setting * @param $setting
*/ */
public function toggleBooleanSetting($setting, Player $player) { public function toggleBooleanSetting($setting, Player $player) {
try {
$scriptSettings = $this->maniaControl->client->getModeScriptSettings(); $scriptSettings = $this->maniaControl->client->getModeScriptSettings();
} catch(\Exception $e) {
return;
}
if (!isset($scriptSettings[$setting])) { if (!isset($scriptSettings[$setting])) {
var_dump('no setting ' . $setting); var_dump('no setting ' . $setting);
return; return;

View File

@ -264,11 +264,6 @@ class ManiaExchangeManager {
$titleId = $this->maniaControl->server->titleId; $titleId = $this->maniaControl->server->titleId;
$titlePrefix = strtolower(substr($titleId, 0, 2)); $titlePrefix = strtolower(substr($titleId, 0, 2));
// Get MapTypes
$scriptInfos = $this->maniaControl->client->getModeScriptInfo();
$mapTypes = $scriptInfos->compatibleMapTypes;
// compile search URL // compile search URL
$url = 'http://' . $titlePrefix . '.mania-exchange.com/tracksearch?api=on'; $url = 'http://' . $titlePrefix . '.mania-exchange.com/tracksearch?api=on';
@ -284,8 +279,15 @@ class ManiaExchangeManager {
$url .= '&priord=' . $searchOrder; $url .= '&priord=' . $searchOrder;
$url .= '&limit=' . $maxMapsReturned; $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) { $fileFunc = function ($mapInfo, $error) use (&$function, $titlePrefix) {
if ($error) { if ($error) {

View File

@ -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_CANCEL_VOTE, AuthenticationManager::AUTH_LEVEL_MODERATOR);
$this->maniaControl->authenticationManager->definePermissionLevel(self::SETTING_PERMISSION_HANDLE_WARMUP, 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 // Extend WarmUp
$this->maniaControl->manialinkManager->registerManialinkPageAnswerListener(self::ACTION_EXTEND_WARMUP, $this, 'command_extendWarmup'); $this->maniaControl->manialinkManager->registerManialinkPageAnswerListener(self::ACTION_EXTEND_WARMUP, $this, 'command_extendWarmup');
$itemQuad = new Quad_BgRaceScore2(); $itemQuad = new Quad_BgRaceScore2();
@ -119,6 +101,28 @@ class ServerCommands implements CallbackListener, CommandListener, ManialinkPage
$itemQuad->setSubStyle($itemQuad::SUBSTYLE_ArrowRed); $itemQuad->setSubStyle($itemQuad::SUBSTYLE_ArrowRed);
$itemQuad->setAction(self::ACTION_CANCEL_VOTE); $itemQuad->setAction(self::ACTION_CANCEL_VOTE);
$this->maniaControl->actionsMenu->addMenuItem($itemQuad, false, 30, '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');
}
} }

View File

@ -242,6 +242,7 @@ class CustomVotesPlugin implements CommandListener, CallbackListener, ManialinkP
$this->addVoteMenuItem($itemQuad, 5, 'Vote for Restart-Map'); $this->addVoteMenuItem($itemQuad, 5, 'Vote for Restart-Map');
//Check if Pause exists in current GameMode //Check if Pause exists in current GameMode
try {
$scriptInfos = $this->maniaControl->client->getModeScriptInfo(); $scriptInfos = $this->maniaControl->client->getModeScriptInfo();
$pauseExists = false; $pauseExists = false;
@ -259,6 +260,9 @@ class CustomVotesPlugin implements CommandListener, CallbackListener, ManialinkP
$itemQuad->setAction(self::ACTION_START_VOTE . 'pausegame'); $itemQuad->setAction(self::ACTION_START_VOTE . 'pausegame');
$this->addVoteMenuItem($itemQuad, 10, 'Vote for a pause of Current Game'); $this->addVoteMenuItem($itemQuad, 10, 'Vote for a pause of Current Game');
} }
} catch(\Exception $e) {
//do nothing
}
//Menu SkipMap //Menu SkipMap
$itemQuad = new Quad_Icons64x64_1(); $itemQuad = new Quad_Icons64x64_1();