exception fixes
This commit is contained in:
parent
071e731537
commit
b1921fcc2b
@ -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;
|
||||
|
@ -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) {
|
||||
|
@ -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');
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user