exception fixes

This commit is contained in:
kremsy 2014-04-22 21:56:18 +02:00 committed by Steffen Schröder
parent 0099970248
commit 2c7cbd0e32
3 changed files with 17 additions and 27 deletions

View File

@ -14,6 +14,7 @@ use ManiaControl\Callbacks\CallbackListener;
use ManiaControl\Callbacks\CallbackManager;
use ManiaControl\ManiaControl;
use ManiaControl\Players\Player;
use Maniaplanet\DedicatedServer\Xmlrpc\LadderModeUnknownException;
/**
* Class offering a Configurator for Server Settings
@ -333,7 +334,13 @@ class ServerSettings implements ConfiguratorMenu, CallbackListener {
if (!$newSettings) {
return true;
}
$this->maniaControl->client->setServerOptions($newSettings);
try {
$this->maniaControl->client->setServerOptions($newSettings);
} catch(LadderModeUnknownException $e) {
$this->maniaControl->chat->sendError("Unknown Ladder-Mode");
return false;
}
// Save Settings into Database
$mysqli = $this->maniaControl->database->mysqli;
@ -352,13 +359,6 @@ class ServerSettings implements ConfiguratorMenu, CallbackListener {
return false;
}
// Notifications
//TODO: clean up those comments
//$settingsCount = count($newSettings);
$settingIndex = 0;
//$title = $this->maniaControl->authenticationManager->getAuthLevelName($player->authLevel);
// $chatMessage = '$ff0' . $title . ' $<' . $player->nickname . '$> set ScriptSetting' . ($settingsCount > 1 ? 's' : '') . ' ';
foreach($newSettings as $setting => $value) {
if ($value === null) {
continue;
@ -372,28 +372,14 @@ class ServerSettings implements ConfiguratorMenu, CallbackListener {
return false;
}
// $chatMessage .= '$<' . '$fff' . preg_replace('/^S_/', '', $setting) . '$z$s$ff0 ';
// $chatMessage .= 'to $fff' . $this->parseSettingValue($value) . '$>';
/*
* if ($settingIndex <= $settingsCount - 2) { $chatMessage .= ', '; }
*/
// Trigger own callback
$this->maniaControl->callbackManager->triggerCallback(self::CB_SERVERSETTING_CHANGED, array(self::CB_SERVERSETTING_CHANGED, $setting, $value));
$settingIndex++;
}
$statement->close();
$this->maniaControl->callbackManager->triggerCallback(self::CB_SERVERSETTINGS_CHANGED, array(self::CB_SERVERSETTINGS_CHANGED));
// $chatMessage .= '!';
// $this->maniaControl->chat->sendInformation($chatMessage);
// $this->maniaControl->log(Formatter::stripCodes($chatMessage));
return true;
}
}

View File

@ -30,6 +30,11 @@ class FaultException extends Exception
return new NotInTeamModeException($faultString, $faultCode);
case 'The map isn\'t in the current selection.':
return new MapNotInCurrentSelectionException($faultString, $faultCode);
case 'Incompatible map type.':
case 'Map not complete.':
return new MapNotCompatibleOrCompleteException($faultString, $faultCode);
case 'Ladder mode unknown.':
return new LadderModeUnknownException($faultString, $faultCode);
}
return new self($faultString, $faultCode);
@ -44,5 +49,7 @@ class ChangeInProgressException extends FaultException {}
class PlayerIsNotSpectatorException extends FaultException {}
class NotInTeamModeException extends FaultException {}
class MapNotInCurrentSelectionException extends FaultException{}
class MapNotCompatibleOrCompleteException extends FaultException{}
class LadderModeUnknownException extends FaultException{}
?>

View File

@ -14,6 +14,7 @@ use ManiaControl\Players\Player;
use Maniaplanet\DedicatedServer\InvalidArgumentException;
use Maniaplanet\DedicatedServer\Xmlrpc\CouldNotWritePlaylistFileException;
use Maniaplanet\DedicatedServer\Xmlrpc\Exception;
use Maniaplanet\DedicatedServer\Xmlrpc\MapNotCompatibleOrCompleteException;
use Maniaplanet\DedicatedServer\Xmlrpc\MapNotInCurrentSelectionException;
use Maniaplanet\DedicatedServer\Xmlrpc\StartIndexOutOfBoundException;
@ -673,11 +674,7 @@ class MapManager implements CallbackListener {
// Check for valid map
try {
$this->maniaControl->client->checkMapForCurrentServerParams($relativeMapFileName);
} catch(Exception $e) {
//TODO temp added 19.04.2014
//TODO except appeared: Map not complete. (wait for possible others)
$this->maniaControl->errorHandler->triggerDebugNotice("Exception line 673 MapManager" . $e->getMessage());
} catch(MapNotCompatibleOrCompleteException $e) {
trigger_error("Couldn't check if map is valid ('{$relativeMapFileName}'). " . $e->getMessage());
$this->maniaControl->chat->sendError('Wrong MapType or not validated!', $login);
return;