From 2c7cbd0e32a8b7a16ee4f9347b4a98b1267f3e96 Mon Sep 17 00:00:00 2001 From: kremsy Date: Tue, 22 Apr 2014 21:56:18 +0200 Subject: [PATCH] exception fixes --- .../core/Configurators/ServerSettings.php | 30 +++++-------------- .../DedicatedServer/Xmlrpc/FaultException.php | 7 +++++ application/core/Maps/MapManager.php | 7 ++--- 3 files changed, 17 insertions(+), 27 deletions(-) diff --git a/application/core/Configurators/ServerSettings.php b/application/core/Configurators/ServerSettings.php index c26e72ee..69b802ca 100644 --- a/application/core/Configurators/ServerSettings.php +++ b/application/core/Configurators/ServerSettings.php @@ -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; } - } diff --git a/application/core/Libs/Maniaplanet/DedicatedServer/Xmlrpc/FaultException.php b/application/core/Libs/Maniaplanet/DedicatedServer/Xmlrpc/FaultException.php index 88d19263..7337563e 100644 --- a/application/core/Libs/Maniaplanet/DedicatedServer/Xmlrpc/FaultException.php +++ b/application/core/Libs/Maniaplanet/DedicatedServer/Xmlrpc/FaultException.php @@ -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{} ?> diff --git a/application/core/Maps/MapManager.php b/application/core/Maps/MapManager.php index 29c183ad..8d07fbb6 100644 --- a/application/core/Maps/MapManager.php +++ b/application/core/Maps/MapManager.php @@ -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;