TrackManiaControl/libs/Maniaplanet/DedicatedServer/Xmlrpc/FaultException.php

171 lines
5.2 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;
2024-08-25 22:30:06 +02:00
class FaultException extends Exception
{
static function create($faultString, $faultCode)
{
2015-06-18 16:18:19 +02:00
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.':
2017-05-12 21:28:26 +02:00
case 'Unable to retrieve validation data. ':
2017-05-24 10:05:28 +02:00
case 'No new replay.':
2014-05-13 17:37:35 +02:00
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);
2024-08-25 22:30:06 +02:00
case 'Can\'t kick server.':
2014-05-08 21:10:56 +02:00
case 'Login or Uid unknown.':
case 'Login unknown.':
2015-02-24 10:26:46 +01:00
case 'Payer login unknown.':
2014-06-12 15:39:50 +02:00
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
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
case 'Player already black listed.':
case 'Player already on guest list.':
case 'Map already added.':
return new AlreadyInListException($faultString, $faultCode);
case 'Login not banned.':
2014-04-24 10:33:47 +02:00
case 'Player not ignored.':
2014-05-13 17:37:35 +02:00
case 'Player not black listed.':
case 'Player not on guest list.':
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
case 'Map not found.':
2014-06-12 15:39:50 +02:00
return new NotInListException($faultString, $faultCode);
2014-05-13 17:37:35 +02:00
case 'Start index out of bound.':
case 'invalid index':
return new IndexOutOfBoundException($faultString, $faultCode);
case 'the next map must be different from the current one.':
2015-01-12 13:39:10 +01:00
case 'No next map currently defined.':
2014-05-13 17:37:35 +02:00
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-08-03 13:02:02 +02:00
case 'Map corrupted.':
2014-06-21 22:36:20 +02:00
case 'Map lightmap is not up to date.':
2017-03-26 19:51:22 +02:00
case 'Map lightmap is not up to date. (will still load for now)':
2014-05-13 17:37:35 +02:00
case 'The map doesn\'t match the server packmask.':
2017-05-15 21:13:06 +02:00
case 'The map environment is not available on the server (doesn\'t match the server packmask).':
2014-05-13 17:37:35 +02:00
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-06-30 23:20:02 +02:00
case 'There are too many players':
case 'There are too many spectators':
2015-01-24 23:29:39 +01:00
case 'Unknown hideserver value':
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.':
case 'Not in script mode.':
case 'Not in Team mode.':
case 'Not in Rounds or Laps mode.':
case 'The scores must be decreasing.':
2015-06-18 16:18:19 +02:00
case 'No current script.':
2014-05-13 17:37:35 +02:00
return new GameModeException($faultString, $faultCode);
2017-03-16 18:20:30 +01:00
case 'couldn\'t write file.':
2014-05-13 17:37:35 +02:00
case 'Unable to write the black list file.':
case 'Unable to write the guest list file.':
case 'Unable to write the playlist file.':
case 'Could not save file.':
case 'Map unknown.':
case 'The playlist file does not exist.':
case 'Invalid url or file.':
case 'Invalid url.':
2017-05-13 19:32:08 +02:00
case 'No map to export in playlist.':
2014-05-13 17:37:35 +02:00
return new FileException($faultString, $faultCode);
}
if (preg_match('~^Unknown command \'.*\'\.$~iu', $faultString)) {
return new GameModeException($faultString, $faultCode);
}
2015-06-18 16:18:19 +02:00
if (preg_match('~^Unknown setting \'.*\'\.$~iu', $faultString)) {
2014-05-13 17:37:35 +02:00
return new GameModeException($faultString, $faultCode);
2015-06-18 16:18:19 +02:00
}
if (preg_match('~^Couldn\'t load \'.*\'\.$~iu', $faultString)) {
2014-05-13 17:37:35 +02:00
return new FileException($faultString, $faultCode);
2015-06-18 16:18:19 +02:00
}
return new self($faultString, $faultCode);
}
}
2024-08-25 22:30:06 +02:00
class AuthenticationException extends FaultException
{
2015-06-18 16:18:19 +02:00
}
2024-08-25 22:30:06 +02:00
class UnavailableFeatureException extends FaultException
{
2015-06-18 16:18:19 +02:00
}
2024-08-25 22:30:06 +02:00
class LockedFeatureException extends FaultException
{
2015-06-18 16:18:19 +02:00
}
2024-08-25 22:30:06 +02:00
class UnknownPlayerException extends FaultException
{
2015-06-18 16:18:19 +02:00
}
2024-08-25 22:30:06 +02:00
class PlayerStateException extends FaultException
{
2015-06-18 16:18:19 +02:00
}
2024-08-25 22:30:06 +02:00
class AlreadyInListException extends FaultException
{
2015-06-18 16:18:19 +02:00
}
2024-08-25 22:30:06 +02:00
class NotInListException extends FaultException
{
2015-06-18 16:18:19 +02:00
}
2024-08-25 22:30:06 +02:00
class IndexOutOfBoundException extends FaultException
{
2015-06-18 16:18:19 +02:00
}
2024-08-25 22:30:06 +02:00
class NextMapException extends FaultException
{
2015-06-18 16:18:19 +02:00
}
2024-08-25 22:30:06 +02:00
class ChangeInProgressException extends FaultException
{
2015-06-18 16:18:19 +02:00
}
2024-08-25 22:30:06 +02:00
class InvalidMapException extends FaultException
{
2015-06-18 16:18:19 +02:00
}
2024-08-25 22:30:06 +02:00
class GameModeException extends FaultException
{
2015-06-18 16:18:19 +02:00
}
2024-08-25 22:30:06 +02:00
class ServerOptionsException extends FaultException
{
2015-06-18 16:18:19 +02:00
}
2024-08-25 22:30:06 +02:00
class FileException extends FaultException
{
2015-06-18 16:18:19 +02:00
}