dedicated-server-api update

This commit is contained in:
Steffen Schröder
2014-05-20 15:20:16 +02:00
parent 33b86cdca0
commit 18cd71818a
6 changed files with 141 additions and 65 deletions

View File

@ -2081,31 +2081,23 @@ class Connection
/**
* Set new server options using the struct passed as parameters.
* Mandatory fields:
* Name, Comment, Password, PasswordForSpectator, CallVoteRatio
* Optional fields:
* NextMaxPlayers, NextMaxSpectators, IsP2PUpload, IsP2PDownload, NextLadderMode,
* NextVehicleNetQuality, NextCallVoteTimeOut, AllowMapDownload, AutoSaveReplays,
* RefereePassword, RefereeMode, AutoSaveValidationReplays, HideServer, UseChangingValidationSeed,
* ClientInputsMaxLatency, DisableHorns, DisableServiceAnnounces, KeepPlayerSlots.
* Name, Comment, Password, PasswordForSpectator and CallVoteRatio.
* Ignored fields:
* LadderServerLimitMin, LadderServerLimitMax and those starting with Current.
* All other fields are optional and can be set to null to be ignored.
* Only available to Admin.
* A change of NextMaxPlayers, NextMaxSpectators, NextLadderMode, NextVehicleNetQuality,
* NextCallVoteTimeOut or UseChangingValidationSeed requires a map restart to be taken into account.
* @param struct $options
* A change of any field starting with Next requires a map restart to be taken into account.
* @param Structures\ServerOptions $options
* @param bool $multicall
* @return bool
* @throws InvalidArgumentException
*/
function setServerOptions($options, $multicall=false)
{
if(!is_array($options)
|| !(isset($options['Name']) && is_string($options['Name']))
|| !(isset($options['Comment']) && is_string($options['Comment']))
|| !(isset($options['Password']) && is_string($options['Password']))
|| !(isset($options['PasswordForSpectator']) && is_string($options['PasswordForSpectator']))
|| !(isset($options['CallVoteRatio']) && Structures\VoteRatio::isRatio($options['CallVoteRatio'])))
if(!($options instanceof Structures\ServerOptions && $options->isValid()))
throw new InvalidArgumentException('options = '.print_r($options, true));
return $this->execute(ucfirst(__FUNCTION__), array($options), $multicall);
return $this->execute(ucfirst(__FUNCTION__), array($options->toSetterArray()), $multicall);
}
/**
@ -2573,42 +2565,42 @@ class Connection
/**
* Get the script cloud variables of given object.
* Only available to Admin.
* @param string $arg1
* @param string $arg2
* @param string $type
* @param string $id
* @param bool $multicall
* @return array
* @throws InvalidArgumentException
*/
function getScriptCloudVariables($arg1, $arg2, $multicall=false)
function getScriptCloudVariables($type, $id, $multicall=false)
{
if(!is_string($arg1))
throw new InvalidArgumentException('$arg1 = '.print_r($arg1, true));
if(!is_string($arg2))
throw new InvalidArgumentException('$arg2 = '.print_r($arg2, true));
if(!is_string($type))
throw new InvalidArgumentException('type = '.print_r($type, true));
if(!is_string($id))
throw new InvalidArgumentException('id = '.print_r($id, true));
return $this->execute(ucfirst(__FUNCTION__), array($arg1, $arg2), $multicall);
return $this->execute(ucfirst(__FUNCTION__), array($type, $id), $multicall);
}
/**
* Set the script cloud variables of given object.
* Only available to Admin.
* @param string $arg1
* @param string $arg2
* @param struct $arg3
* @param string $type
* @param string $id
* @param mixed[] $variables {mixed <variable name>, ...}
* @param bool $multicall
* @return bool
* @throws InvalidArgumentException
*/
function setScriptCloudVariables($arg1, $arg2, $arg3, $multicall=false)
function setScriptCloudVariables($type, $id, $variables, $multicall=false)
{
if(!is_string($arg1))
throw new InvalidArgumentException('$arg1 = '.print_r($arg1, true));
if(!is_string($arg2))
throw new InvalidArgumentException('$arg2 = '.print_r($arg2, true));
if(!is_struct($arg3))
throw new InvalidArgumentException('$arg3 = '.print_r($arg3, true));
if(!is_string($type))
throw new InvalidArgumentException('type = '.print_r($type, true));
if(!is_string($id))
throw new InvalidArgumentException('id = '.print_r($id, true));
if(!is_array($variables) || !$variables)
throw new InvalidArgumentException('variables = '.print_r($variables, true));
return $this->execute(ucfirst(__FUNCTION__), array($arg1, $arg2, $arg3), $multicall);
return $this->execute(ucfirst(__FUNCTION__), array($type, $id, $variables), $multicall);
}
/**
@ -3548,7 +3540,7 @@ class Connection
/**
* Set as next maps the list of maps with the specified filenames, if they are present in the selection.
* Only available to Admin.
* @param array $filenames Relative to the Maps path
* @param string[] $filenames Relative to the Maps path
* @param bool $multicall
* @return int Number of maps actually chosen
* @throws InvalidArgumentException
@ -3942,6 +3934,46 @@ class Connection
return $this->execute(ucfirst(__FUNCTION__), array(), $multicall);
}
/**
* Join the server on lan.
* Only available on client.
* Only available to Admin.
* @param string $host IPv4 with optionally a port (eg. '192.168.1.42:2350')
* @param string $password
* @param bool $multicall
* @return bool
* @throws InvalidArgumentException
*/
function joinServerLan($host, $password='', $multicall=false)
{
if(!is_string($host))
throw new InvalidArgumentException('host = '.print_r($host, true));
if(!is_string($password))
throw new InvalidArgumentException('password = '.print_r($password, true));
return $this->execute(ucfirst(__FUNCTION__), array(array('Server' => $host, 'ServerPassword' => $password)), $multicall);
}
/**
* Join the server on internet.
* Only available on client.
* Only available to Admin.
* @param string $host Server login or IPv4 with optionally a port (eg. '192.168.1.42:2350')
* @param string $password
* @param bool $multicall
* @return bool
* @throws InvalidArgumentException
*/
function joinServerInternet($host, $password='', $multicall=false)
{
if(!is_string($host))
throw new InvalidArgumentException('host = '.print_r($host, true));
if(!is_string($password))
throw new InvalidArgumentException('password = '.print_r($password, true));
return $this->execute(ucfirst(__FUNCTION__), array(array('Server' => $host, 'ServerPassword' => $password)), $multicall);
}
/**
* Returns the login of the given player
* @param mixed $player