updated dedicated-server-api

This commit is contained in:
Steffen Schröder committed 2014-06-12 15:39:50 +02:00
1 parent 8559799907
commit d44de5f49e
39 files changed
+480 -261

No files matched your search

File diff suppressed because it is too large. Load diff
File mode changed.
View File
File mode changed.
File mode changed.
+10
View File
@@ -13,4 +13,14 @@ class FileDesc extends AbstractStructure
public $fileName; public $fileName;
/** @var string */ /** @var string */
public $checksum; public $checksum;
/**
* @return FileDesc
*/
public static function fromArray($array)
{
$object = parent::fromArray($array);
$object->fileName = str_replace("\xEF\xBB\xBF", '', $object->fileName);
return $object;
}
} }
File mode changed.
File mode changed.
File mode changed.
File mode changed.
File mode changed.
+10
View File
@@ -41,4 +41,14 @@ class Map extends AbstractStructure
public $mapType; public $mapType;
/** var string */ /** var string */
public $mapStyle; public $mapStyle;
/**
* @return Map
*/
public static function fromArray($array)
{
$object = parent::fromArray($array);
$object->fileName = str_replace("\xEF\xBB\xBF", '', $object->fileName);
return $object;
}
} }
View File
File mode changed.
+10
View File
@@ -15,4 +15,14 @@ class Music extends AbstractStructure
public $url; public $url;
/** var string */ /** var string */
public $file; public $file;
/**
* @return Music
*/
public static function fromArray($array)
{
$object = parent::fromArray($array);
$object->file = str_replace("\xEF\xBB\xBF", '', $object->file);
return $object;
}
} }
File mode changed.
File mode changed.
File mode changed.
File mode changed.
File mode changed.
File mode changed.
File mode changed.
File mode changed.
+4 -1
View File
@@ -22,7 +22,10 @@ class ScriptInfo extends AbstractStructure
/** @var Command[] */ /** @var Command[] */
public $commandDescs = array(); public $commandDescs = array();
static public function fromArray($array) /**
* @return ScriptInfo
*/
public static function fromArray($array)
{ {
$object = parent::fromArray($array); $object = parent::fromArray($array);
$object->paramDescs = ScriptSettings::fromArrayOfArray($object->paramDescs); $object->paramDescs = ScriptSettings::fromArrayOfArray($object->paramDescs);
File mode changed.
File mode changed.
+4 -1
View File
@@ -14,7 +14,10 @@ class Skin extends AbstractStructure
/** @var FileDesc */ /** @var FileDesc */
public $packDesc; public $packDesc;
static function fromArray($array) /**
* @return Skin
*/
public static function fromArray($array)
{ {
$object = parent::fromArray($array); $object = parent::fromArray($array);
$object->packDesc = FileDesc::fromArray($object->packDesc); $object->packDesc = FileDesc::fromArray($object->packDesc);
File mode changed.
File mode changed.
View File
File mode changed.
View File
File mode changed.
File mode changed.
File mode changed.
View File
File mode changed.
File mode changed.
File mode changed.
View File
File mode changed.
View File
File mode changed.
+2 -73
View File
@@ -34,35 +34,26 @@ class FaultException extends Exception
return new LockedFeatureException($faultString, $faultCode); return new LockedFeatureException($faultString, $faultCode);
case 'Login or Uid unknown.': case 'Login or Uid unknown.':
case 'Login unknown.': case 'Login unknown.':
return new LoginUnknownException($faultString, $faultCode); //@todo remove this line return new UnknownPlayerException($faultString, $faultCode);
//return new UnknownPlayerException($faultString, $faultCode);
case 'The player is not a spectator': case 'The player is not a spectator':
case 'The player is not a spectator.': case 'The player is not a spectator.':
return new PlayerIsNotSpectatorException($faultString, $faultCode); //@todo remove this line
case 'Not a network player.': case 'Not a network player.':
case 'Player is not a fake player': case 'Player is not a fake player':
return new PlayerStateException($faultString, $faultCode); return new PlayerStateException($faultString, $faultCode);
case 'Player already ignored.': case 'Player already ignored.':
return new PlayerAlreadyIgnoredException($faultString, $faultCode); //@todo remove this line
case 'Player already black listed.': case 'Player already black listed.':
case 'Player already on guest list.': case 'Player already on guest list.':
case 'Map already added.': case 'Map already added.':
return new AlreadyInListException($faultString, $faultCode); return new AlreadyInListException($faultString, $faultCode);
case 'Login not banned.': case 'Login not banned.':
return new NotInListException($faultString, $faultCode); //@todo remove this line
case 'Player not ignored.': case 'Player not ignored.':
return new PlayerNotIgnoredException($faultString, $faultCode); //@todo remove this line
case 'Player not black listed.': case 'Player not black listed.':
case 'Player not on guest list.': case 'Player not on guest list.':
return new NotInListException($faultString, $faultCode); //@todo remove this line
case 'Map not in the selection.': case 'Map not in the selection.':
case 'The map isn\'t in the current selection.': case 'The map isn\'t in the current selection.':
return new MapNotInCurrentSelectionException($faultString, $faultCode); //@todo remove this line
case 'Map not found.': case 'Map not found.':
return new MapNotFoundException($faultString, $faultCode); //@todo remove this line return new NotInListException($faultString, $faultCode);
//return new NotInListException($faultString, $faultCode);
case 'Start index out of bound.': case 'Start index out of bound.':
return new StartIndexOutOfBoundException($faultString, $faultCode); //@todo remove this line
case 'invalid index': case 'invalid index':
return new IndexOutOfBoundException($faultString, $faultCode); return new IndexOutOfBoundException($faultString, $faultCode);
case 'the next map must be different from the current one.': case 'the next map must be different from the current one.':
@@ -71,7 +62,6 @@ class FaultException extends Exception
return new ChangeInProgressException($faultString, $faultCode); return new ChangeInProgressException($faultString, $faultCode);
case 'Incompatible map type.': case 'Incompatible map type.':
case 'Map not complete.': case 'Map not complete.':
return new MapNotCompatibleOrCompleteException($faultString, $faultCode); //@todo remove this line
case 'The map doesn\'t match the server packmask.': case 'The map doesn\'t match the server packmask.':
return new InvalidMapException($faultString, $faultCode); return new InvalidMapException($faultString, $faultCode);
case 'Ladder mode unknown.': case 'Ladder mode unknown.':
@@ -80,19 +70,14 @@ class FaultException extends Exception
return new ServerOptionsException($faultString, $faultCode); return new ServerOptionsException($faultString, $faultCode);
case 'New mode unknown.': case 'New mode unknown.':
case 'You need to stop the server to change to/from script mode.': 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.': case 'Not in script mode.':
return new NotInScriptModeException($faultString, $faultCode); //@todo remove this line
case 'Not in Team mode.': case 'Not in Team mode.':
return new NotInTeamModeException($faultString, $faultCode); //@todo remove this line
case 'Not in Rounds or Laps mode.': case 'Not in Rounds or Laps mode.':
case 'The scores must be decreasing.': case 'The scores must be decreasing.':
return new GameModeException($faultString, $faultCode); return new GameModeException($faultString, $faultCode);
case 'Unable to write the black list file.': case 'Unable to write the black list file.':
case 'Unable to write the guest 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.': case 'Unable to write the playlist file.':
return new CouldNotWritePlaylistFileException($faultString, $faultCode); //@todo remove this line
case 'Could not save file.': case 'Could not save file.':
case 'Map unknown.': case 'Map unknown.':
case 'The playlist file does not exist.': case 'The playlist file does not exist.':
@@ -123,59 +108,3 @@ class InvalidMapException extends FaultException{}
class GameModeException extends FaultException {} class GameModeException extends FaultException {}
class ServerOptionsException extends FaultException {} class ServerOptionsException extends FaultException {}
class FileException 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 {}
@@ -150,12 +150,17 @@ class GbxRemote
switch(count($this->multicallBuffer)) switch(count($this->multicallBuffer))
{ {
case 0: case 0:
return; return array();
case 1: case 1:
$call = array_shift($this->multicallBuffer); $call = array_shift($this->multicallBuffer);
return $this->query($call['methodName'], $call['params']); return array($this->query($call['methodName'], $call['params']));
default: default:
$result = $this->query('system.multicall', array($this->multicallBuffer)); $result = $this->query('system.multicall', array($this->multicallBuffer));
foreach($result as &$value)
if(isset($value['faultCode']))
$value = FaultException::create($value['faultString'], $value['faultCode']);
else
$value = $value[0];
$this->multicallBuffer = array(); $this->multicallBuffer = array();
return $result; return $result;
} }
+8 -8
View File
@@ -13,7 +13,7 @@ if(extension_loaded('xmlrpc'))
{ {
private static $options = array( private static $options = array(
'encoding' => 'utf-8', 'encoding' => 'utf-8',
'escaping' => 'cdata', 'escaping' => 'markup',
'verbosity' => 'no_white_space' 'verbosity' => 'no_white_space'
); );
@@ -83,11 +83,11 @@ else
switch(gettype($v)) switch(gettype($v))
{ {
case 'boolean': case 'boolean':
return '<boolean>'.self::escape((int) $v, $escape).'</boolean>'; return '<boolean>'.((int) $v).'</boolean>';
case 'integer': case 'integer':
return '<int>'.self::escape($v, $escape).'</int>'; return '<int>'.$v.'</int>';
case 'double': case 'double':
return '<double>'.self::escape($v, $escape).'</double>'; return '<double>'.$v.'</double>';
case 'string': case 'string':
case 'NULL': case 'NULL':
if(!$v) if(!$v)
@@ -98,17 +98,17 @@ else
{ {
if(!$v->scalar) if(!$v->scalar)
return '<base64/>'; return '<base64/>';
return '<base64>'.self::escape(base64_encode($v->scalar), $escape).'</base64>'; return '<base64>'.base64_encode($v->scalar).'</base64>';
} }
if($v instanceof \DateTime) if($v instanceof \DateTime)
return '<dateTime.iso8601>'.self::escape($v->format(self::DATE_FORMAT), $escape).'</dateTime.iso8601>'; return '<dateTime.iso8601>'.$v->format(self::DATE_FORMAT).'</dateTime.iso8601>';
$v = get_object_vars($v); $v = get_object_vars($v);
// fallthrough // fallthrough
case 'array': case 'array':
$return = '';
// empty array case // empty array case
if(!$v) if(!$v)
return '<array><data/></array>'; return '<array><data/></array>';
$return = '';
// pure array case // pure array case
if(array_keys($v) === range(0, count($v) - 1)) if(array_keys($v) === range(0, count($v) - 1))
{ {
@@ -132,7 +132,7 @@ else
private static function escape($str, $escape=true) private static function escape($str, $escape=true)
{ {
if($escape) if($escape)
return '<![CDATA['.$str.']]>'; return '<![CDATA['.str_replace(']]>', ']]]]><![CDATA[>', $str).']]>';
return $str; return $str;
} }