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\Callbacks\CallbackManager;
use ManiaControl\ManiaControl; use ManiaControl\ManiaControl;
use ManiaControl\Players\Player; use ManiaControl\Players\Player;
use Maniaplanet\DedicatedServer\Xmlrpc\LadderModeUnknownException;
/** /**
* Class offering a Configurator for Server Settings * Class offering a Configurator for Server Settings
@ -333,7 +334,13 @@ class ServerSettings implements ConfiguratorMenu, CallbackListener {
if (!$newSettings) { if (!$newSettings) {
return true; return true;
} }
try {
$this->maniaControl->client->setServerOptions($newSettings); $this->maniaControl->client->setServerOptions($newSettings);
} catch(LadderModeUnknownException $e) {
$this->maniaControl->chat->sendError("Unknown Ladder-Mode");
return false;
}
// Save Settings into Database // Save Settings into Database
$mysqli = $this->maniaControl->database->mysqli; $mysqli = $this->maniaControl->database->mysqli;
@ -352,13 +359,6 @@ class ServerSettings implements ConfiguratorMenu, CallbackListener {
return false; 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) { foreach($newSettings as $setting => $value) {
if ($value === null) { if ($value === null) {
continue; continue;
@ -372,28 +372,14 @@ class ServerSettings implements ConfiguratorMenu, CallbackListener {
return false; 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 // Trigger own callback
$this->maniaControl->callbackManager->triggerCallback(self::CB_SERVERSETTING_CHANGED, array(self::CB_SERVERSETTING_CHANGED, $setting, $value)); $this->maniaControl->callbackManager->triggerCallback(self::CB_SERVERSETTING_CHANGED, array(self::CB_SERVERSETTING_CHANGED, $setting, $value));
$settingIndex++;
} }
$statement->close(); $statement->close();
$this->maniaControl->callbackManager->triggerCallback(self::CB_SERVERSETTINGS_CHANGED, array(self::CB_SERVERSETTINGS_CHANGED)); $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; return true;
} }
} }

View File

@ -30,6 +30,11 @@ class FaultException extends Exception
return new NotInTeamModeException($faultString, $faultCode); return new NotInTeamModeException($faultString, $faultCode);
case 'The map isn\'t in the current selection.': case 'The map isn\'t in the current selection.':
return new MapNotInCurrentSelectionException($faultString, $faultCode); 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); return new self($faultString, $faultCode);
@ -44,5 +49,7 @@ class ChangeInProgressException extends FaultException {}
class PlayerIsNotSpectatorException extends FaultException {} class PlayerIsNotSpectatorException extends FaultException {}
class NotInTeamModeException extends FaultException {} class NotInTeamModeException extends FaultException {}
class MapNotInCurrentSelectionException 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\InvalidArgumentException;
use Maniaplanet\DedicatedServer\Xmlrpc\CouldNotWritePlaylistFileException; use Maniaplanet\DedicatedServer\Xmlrpc\CouldNotWritePlaylistFileException;
use Maniaplanet\DedicatedServer\Xmlrpc\Exception; use Maniaplanet\DedicatedServer\Xmlrpc\Exception;
use Maniaplanet\DedicatedServer\Xmlrpc\MapNotCompatibleOrCompleteException;
use Maniaplanet\DedicatedServer\Xmlrpc\MapNotInCurrentSelectionException; use Maniaplanet\DedicatedServer\Xmlrpc\MapNotInCurrentSelectionException;
use Maniaplanet\DedicatedServer\Xmlrpc\StartIndexOutOfBoundException; use Maniaplanet\DedicatedServer\Xmlrpc\StartIndexOutOfBoundException;
@ -673,11 +674,7 @@ class MapManager implements CallbackListener {
// Check for valid map // Check for valid map
try { try {
$this->maniaControl->client->checkMapForCurrentServerParams($relativeMapFileName); $this->maniaControl->client->checkMapForCurrentServerParams($relativeMapFileName);
} catch(Exception $e) { } catch(MapNotCompatibleOrCompleteException $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());
trigger_error("Couldn't check if map is valid ('{$relativeMapFileName}'). " . $e->getMessage()); trigger_error("Couldn't check if map is valid ('{$relativeMapFileName}'). " . $e->getMessage());
$this->maniaControl->chat->sendError('Wrong MapType or not validated!', $login); $this->maniaControl->chat->sendError('Wrong MapType or not validated!', $login);
return; return;