TrackManiaControl/application/core/Libs/Maniaplanet/DedicatedServer/Xmlrpc/FaultException.php

182 lines
7.0 KiB
PHP
Raw Normal View History

<?php
/**
* ManiaPlanet dedicated server Xml-RPC client
*
* @license http://www.gnu.org/licenses/lgpl.html LGPL License 3
*/
namespace Maniaplanet\DedicatedServer\Xmlrpc;
class FaultException extends Exception
{
static function create($faultString, $faultCode)
{
switch($faultString)
{
2014-05-13 17:37:35 +02:00
case 'Password incorrect.':
case 'Permission denied.':
return new AuthenticationException($faultString, $faultCode);
case 'not connected to the internet':
case 'Not connected to the masterserver.':
case 'Not a game server.':
case 'Not a server.':
case 'Couldn\'t create the fake player.':
case 'Only server can receive a callvote':
case 'No map currently loaded.':
case 'No replay to save':
case 'Internal error.':
return new UnavailableFeatureException($faultString, $faultCode);
case 'You must enable the callbacks to be able to do chat routing.':
case 'Chat routing not enabled.':
case 'Script cloud disabled.':
case 'Already waiting for a vote.':
case 'You must stop server first.':
return new LockedFeatureException($faultString, $faultCode);
2014-05-08 21:10:56 +02:00
case 'Login or Uid unknown.':
case 'Login unknown.':
2014-05-13 17:37:35 +02:00
return new LoginUnknownException($faultString, $faultCode); //@todo remove this line
//return new UnknownPlayerException($faultString, $faultCode);
2014-04-19 23:14:37 +02:00
case 'The player is not a spectator':
2014-04-21 23:14:06 +02:00
case 'The player is not a spectator.':
2014-05-13 17:37:35 +02:00
return new PlayerIsNotSpectatorException($faultString, $faultCode); //@todo remove this line
case 'Not a network player.':
case 'Player is not a fake player':
return new PlayerStateException($faultString, $faultCode);
2014-04-24 10:33:47 +02:00
case 'Player already ignored.':
2014-05-13 17:37:35 +02:00
return new PlayerAlreadyIgnoredException($faultString, $faultCode); //@todo remove this line
case 'Player already black listed.':
case 'Player already on guest list.':
case 'Map already added.':
return new AlreadyInListException($faultString, $faultCode);
case 'Login not banned.':
return new NotInListException($faultString, $faultCode); //@todo remove this line
2014-04-24 10:33:47 +02:00
case 'Player not ignored.':
2014-05-13 17:37:35 +02:00
return new PlayerNotIgnoredException($faultString, $faultCode); //@todo remove this line
case 'Player not black listed.':
case 'Player not on guest list.':
return new NotInListException($faultString, $faultCode); //@todo remove this line
case 'Map not in the selection.':
2014-04-21 23:14:06 +02:00
case 'The map isn\'t in the current selection.':
2014-05-13 17:37:35 +02:00
return new MapNotInCurrentSelectionException($faultString, $faultCode); //@todo remove this line
case 'Map not found.':
return new MapNotFoundException($faultString, $faultCode); //@todo remove this line
//return new NotInListException($faultString, $faultCode);
case 'Start index out of bound.':
return new StartIndexOutOfBoundException($faultString, $faultCode); //@todo remove this line
case 'invalid index':
return new IndexOutOfBoundException($faultString, $faultCode);
case 'the next map must be different from the current one.':
return new NextMapException($faultString, $faultCode);
case 'Change in progress.':
return new ChangeInProgressException($faultString, $faultCode);
2014-04-22 21:56:18 +02:00
case 'Incompatible map type.':
case 'Map not complete.':
2014-05-13 17:37:35 +02:00
return new MapNotCompatibleOrCompleteException($faultString, $faultCode); //@todo remove this line
case 'The map doesn\'t match the server packmask.':
return new InvalidMapException($faultString, $faultCode);
2014-04-22 21:56:18 +02:00
case 'Ladder mode unknown.':
2014-05-08 21:10:56 +02:00
case 'You cannot change the max players count: AllowSpectatorRelays is activated.':
2014-05-13 17:37:35 +02:00
case 'You cannot change the max spectators count: AllowSpectatorRelays is activated.':
2014-05-08 21:10:56 +02:00
return new ServerOptionsException($faultString, $faultCode);
2014-05-13 17:37:35 +02:00
case 'New mode unknown.':
case 'You need to stop the server to change to/from script mode.':
return new GameModeException($faultString, $faultCode); //@todo remove this line
case 'Not in script mode.':
return new NotInScriptModeException($faultString, $faultCode); //@todo remove this line
case 'Not in Team mode.':
return new NotInTeamModeException($faultString, $faultCode); //@todo remove this line
case 'Not in Rounds or Laps mode.':
case 'The scores must be decreasing.':
return new GameModeException($faultString, $faultCode);
case 'Unable to write the black list file.':
case 'Unable to write the guest list file.':
return new FileException($faultString, $faultCode); //@todo remove this line
case 'Unable to write the playlist file.':
return new CouldNotWritePlaylistFileException($faultString, $faultCode); //@todo remove this line
case 'Could not save file.':
case 'Map unknown.':
case 'The playlist file does not exist.':
case 'Invalid url or file.':
case 'Invalid url.':
return new FileException($faultString, $faultCode);
}
2014-05-13 17:37:35 +02:00
if(preg_match('~^Unknown setting \'.*\'\.$~iu', $faultString))
return new GameModeException($faultString, $faultCode);
if(preg_match('~^Couldn\'t load \'.*\'\.$~iu', $faultString))
return new FileException($faultString, $faultCode);
return new self($faultString, $faultCode);
}
}
2014-05-13 17:37:35 +02:00
class AuthenticationException extends FaultException {}
class UnavailableFeatureException extends FaultException {}
class LockedFeatureException extends FaultException {}
class UnknownPlayerException extends FaultException {}
class PlayerStateException extends FaultException {}
class AlreadyInListException extends FaultException {}
class NotInListException extends FaultException {}
class IndexOutOfBoundException extends FaultException {}
2014-05-08 23:43:30 +02:00
class NextMapException extends FaultException{}
2014-05-13 17:37:35 +02:00
class ChangeInProgressException extends FaultException {}
class InvalidMapException extends FaultException{}
class GameModeException extends FaultException {}
class ServerOptionsException extends FaultException {}
class FileException extends FaultException {}
/**
* @deprecated
* @see UnknownPlayerException
*/
class LoginUnknownException extends UnknownPlayerException {}
/**
* @deprecated
* @see FileException
*/
class CouldNotWritePlaylistFileException extends FileException {}
/**
* @deprecated
* @see IndexOutOfBoundException
*/
class StartIndexOutOfBoundException extends IndexOutOfBoundException {}
/**
* @deprecated
* @see GameModeException
*/
class NotInScriptModeException extends GameModeException {}
/**
* @deprecated
* @see PlayerStateException
*/
class PlayerIsNotSpectatorException extends PlayerStateException {}
/**
* @deprecated
* @see AlreadyInListException
*/
class PlayerAlreadyIgnoredException extends AlreadyInListException {}
/**
* @deprecated
* @see NotInListException
*/
class PlayerNotIgnoredException extends NotInListException {}
/**
* @deprecated
* @see GameModeException
*/
class NotInTeamModeException extends GameModeException {}
/**
* @deprecated
* @see NotInListException
*/
class MapNotInCurrentSelectionException extends NotInListException {}
/**
* @deprecated
* @see InvalidMapException
*/
class MapNotCompatibleOrCompleteException extends InvalidMapException {}
/**
* @deprecated
* @see NotInListException
*/
class MapNotFoundException extends NotInListException {}