dedicated server api update (reverted from commit 77a53b282c
)
This commit is contained in:
parent
77a53b282c
commit
aefa91fc15
File diff suppressed because it is too large
Load Diff
@ -4,7 +4,7 @@
|
||||
*
|
||||
* @license http://www.gnu.org/licenses/lgpl.html LGPL License 3
|
||||
*/
|
||||
|
||||
|
||||
namespace Maniaplanet\DedicatedServer\Structures;
|
||||
|
||||
abstract class AbstractStructure
|
||||
@ -13,37 +13,37 @@ abstract class AbstractStructure
|
||||
{
|
||||
if(!is_array($array))
|
||||
return $array;
|
||||
|
||||
|
||||
$object = new static;
|
||||
foreach($array as $key => $value)
|
||||
$object->{lcfirst($key)} = $value;
|
||||
return $object;
|
||||
}
|
||||
|
||||
|
||||
static public function fromArrayOfArray($array)
|
||||
{
|
||||
if(!is_array($array))
|
||||
return $array;
|
||||
|
||||
|
||||
$result = array();
|
||||
foreach($array as $key => $value)
|
||||
$result[$key] = static::fromArray($value);
|
||||
return $result;
|
||||
}
|
||||
|
||||
|
||||
static public function getPropertyFromArray($array, $property)
|
||||
{
|
||||
return array_map(get_called_class().'::extractProperty', $array, array_fill(0, count($array), $property));
|
||||
}
|
||||
|
||||
|
||||
static protected function extractProperty($element, $property)
|
||||
{
|
||||
if(!is_a($element, get_called_class()) || !property_exists($element, $property))
|
||||
throw new \InvalidArgumentException('property '.$property.' does not exists in class: '.get_called_class());
|
||||
|
||||
|
||||
return $element->$property;
|
||||
}
|
||||
|
||||
|
||||
function toArray()
|
||||
{
|
||||
$out = array();
|
||||
@ -52,3 +52,5 @@ abstract class AbstractStructure
|
||||
return $out;
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
@ -4,7 +4,6 @@
|
||||
*
|
||||
* @license http://www.gnu.org/licenses/lgpl.html LGPL License 3
|
||||
*/
|
||||
|
||||
namespace Maniaplanet\DedicatedServer\Structures;
|
||||
|
||||
class Bill extends AbstractStructure
|
||||
@ -15,11 +14,9 @@ class Bill extends AbstractStructure
|
||||
const STATE_PAYED = 4;
|
||||
const STATE_REFUSED = 5;
|
||||
const STATE_ERROR = 6;
|
||||
|
||||
/** @var int */
|
||||
|
||||
public $state;
|
||||
/** @var string */
|
||||
public $stateName;
|
||||
/** @var int */
|
||||
public $transactionId;
|
||||
}
|
||||
?>
|
@ -1,20 +1,18 @@
|
||||
<?php
|
||||
/**
|
||||
* ManiaPlanet dedicated server Xml-RPC client
|
||||
*
|
||||
* @license http://www.gnu.org/licenses/lgpl.html LGPL License 3
|
||||
*/
|
||||
|
||||
/**
|
||||
* @version $Revision: $:
|
||||
* @author $Author: $:
|
||||
* @date $Date: $:
|
||||
*/
|
||||
namespace Maniaplanet\DedicatedServer\Structures;
|
||||
|
||||
class Command extends AbstractStructure
|
||||
{
|
||||
/** @var string */
|
||||
public $name;
|
||||
/** @var string */
|
||||
public $desc;
|
||||
/** @var string */
|
||||
public $type;
|
||||
/** @var string */
|
||||
public $default;
|
||||
}
|
||||
|
||||
?>
|
||||
|
@ -4,7 +4,6 @@
|
||||
*
|
||||
* @license http://www.gnu.org/licenses/lgpl.html LGPL License 3
|
||||
*/
|
||||
|
||||
namespace Maniaplanet\DedicatedServer\Structures;
|
||||
|
||||
class GameInfos extends AbstractStructure
|
||||
@ -20,52 +19,29 @@ class GameInfos extends AbstractStructure
|
||||
const GAMEMODE_CUP = 5;
|
||||
const GAMEMODE_STUNTS = 6;
|
||||
|
||||
/** @var int */
|
||||
public $gameMode;
|
||||
/** @var string */
|
||||
public $scriptName;
|
||||
/** @var int */
|
||||
public $nbMaps;
|
||||
/** @var int */
|
||||
public $chatTime;
|
||||
/** @var int */
|
||||
public $finishTimeout;
|
||||
/** @var int */
|
||||
public $allWarmUpDuration;
|
||||
/** @var bool */
|
||||
public $disableRespawn;
|
||||
/** @var int */
|
||||
public $forceShowAllOpponents;
|
||||
/** @var int */
|
||||
public $roundsPointsLimit;
|
||||
/** @var int */
|
||||
public $roundsForcedLaps;
|
||||
/** @var bool */
|
||||
public $roundsUseNewRules;
|
||||
/** @var int */
|
||||
public $roundsPointsLimitNewRules;
|
||||
/** @var int */
|
||||
public $teamPointsLimit;
|
||||
/** @var int */
|
||||
public $teamMaxPoints;
|
||||
/** @var bool */
|
||||
public $teamUseNewRules;
|
||||
/** @var int */
|
||||
public $teamPointsLimitNewRules;
|
||||
/** @var int */
|
||||
public $timeAttackLimit;
|
||||
/** @var int */
|
||||
public $timeAttackSynchStartPeriod;
|
||||
/** @var int */
|
||||
public $lapsNbLaps;
|
||||
/** @var int */
|
||||
public $lapsTimeLimit;
|
||||
/** @var int */
|
||||
public $cupPointsLimit;
|
||||
/** @var int */
|
||||
public $cupRoundsPerMap;
|
||||
/** @var int */
|
||||
public $cupNbWinners;
|
||||
/** @var int */
|
||||
public $cupWarmUpDuration;
|
||||
}
|
||||
?>
|
||||
|
@ -4,17 +4,14 @@
|
||||
*
|
||||
* @license http://www.gnu.org/licenses/lgpl.html LGPL License 3
|
||||
*/
|
||||
|
||||
namespace Maniaplanet\DedicatedServer\Structures;
|
||||
|
||||
class LobbyInfo extends AbstractStructure
|
||||
{
|
||||
/** var bool */
|
||||
public $isLobby;
|
||||
/** var int */
|
||||
public $lobbyPlayers;
|
||||
/** var int */
|
||||
public $lobbyMaxPlayers;
|
||||
/** var float */
|
||||
public $lobbyPlayersLevel;
|
||||
}
|
||||
|
||||
?>
|
@ -4,41 +4,24 @@
|
||||
*
|
||||
* @license http://www.gnu.org/licenses/lgpl.html LGPL License 3
|
||||
*/
|
||||
|
||||
namespace Maniaplanet\DedicatedServer\Structures;
|
||||
|
||||
class Map extends AbstractStructure
|
||||
{
|
||||
/** var string */
|
||||
public $uId;
|
||||
/** var string */
|
||||
public $name;
|
||||
/** var string */
|
||||
public $fileName;
|
||||
/** var string */
|
||||
public $author;
|
||||
/** var string */
|
||||
public $environnement;
|
||||
/** var string */
|
||||
public $mood;
|
||||
/** var int */
|
||||
public $bronzeTime;
|
||||
/** var int */
|
||||
public $silverTime;
|
||||
/** var int */
|
||||
public $goldTime;
|
||||
/** var int */
|
||||
public $authorTime;
|
||||
/** var int */
|
||||
public $copperPrice;
|
||||
/** var bool */
|
||||
public $lapRace;
|
||||
/** var int */
|
||||
public $nbLaps;
|
||||
/** var int */
|
||||
public $nbCheckpoints;
|
||||
/** var string */
|
||||
public $mapType;
|
||||
/** var string */
|
||||
public $mapStyle;
|
||||
}
|
||||
}
|
@ -4,13 +4,15 @@
|
||||
*
|
||||
* @license http://www.gnu.org/licenses/lgpl.html LGPL License 3
|
||||
*/
|
||||
|
||||
namespace Maniaplanet\DedicatedServer\Structures;
|
||||
|
||||
class Mod extends AbstractStructure
|
||||
{
|
||||
/** var string */
|
||||
public $env;
|
||||
/** var string */
|
||||
public $url;
|
||||
}
|
||||
|
||||
function toArray()
|
||||
{
|
||||
return array('Env'=>$this->env,'Url'=>$this->url);
|
||||
}
|
||||
}
|
@ -4,15 +4,11 @@
|
||||
*
|
||||
* @license http://www.gnu.org/licenses/lgpl.html LGPL License 3
|
||||
*/
|
||||
|
||||
namespace Maniaplanet\DedicatedServer\Structures;
|
||||
|
||||
class Music extends AbstractStructure
|
||||
{
|
||||
/** var bool */
|
||||
public $override;
|
||||
/** var string */
|
||||
public $url;
|
||||
/** var string */
|
||||
public $url;
|
||||
public $file;
|
||||
}
|
||||
}
|
@ -4,34 +4,24 @@
|
||||
*
|
||||
* @license http://www.gnu.org/licenses/lgpl.html LGPL License 3
|
||||
*/
|
||||
|
||||
namespace Maniaplanet\DedicatedServer\Structures;
|
||||
|
||||
class NetworkStats extends AbstractStructure
|
||||
{
|
||||
/** @var int */
|
||||
public $uptime;
|
||||
/** @var int */
|
||||
public $nbrConnection;
|
||||
/** @var int */
|
||||
public $meanConnectionTime;
|
||||
/** @var int */
|
||||
public $meanNbrPlayer;
|
||||
/** @var int */
|
||||
public $recvNetRate;
|
||||
/** @var int */
|
||||
public $sendNetRate;
|
||||
/** @var int */
|
||||
public $totalReceivingSize;
|
||||
/** @var int */
|
||||
public $totalSendingSize;
|
||||
/** @var PlayerNetInfo[] */
|
||||
public $playerNetInfos;
|
||||
|
||||
static public function fromArray($array)
|
||||
{
|
||||
$object = parent::fromArray($array);
|
||||
$object->playerNetInfos = PlayerNetInfo::fromArrayOfArray($object->playerNetInfos);
|
||||
$object->playerNetInfos = Player::fromArrayOfArray($object->playerNetInfos);
|
||||
return $object;
|
||||
}
|
||||
}
|
||||
}
|
@ -8,6 +8,90 @@ namespace Maniaplanet\DedicatedServer\Structures;
|
||||
|
||||
class Player extends AbstractStructure
|
||||
{
|
||||
/** @var string */
|
||||
public $playerId;
|
||||
public $login;
|
||||
public $nickName;
|
||||
public $teamId;
|
||||
public $path;
|
||||
public $language;
|
||||
public $clientVersion;
|
||||
public $clientName;
|
||||
public $iPAddress;
|
||||
public $downloadRate;
|
||||
public $uploadRate;
|
||||
public $isSpectator;
|
||||
public $isInOfficialMode;
|
||||
public $avatar;
|
||||
public $skins;
|
||||
public $ladderStats;
|
||||
public $hoursSinceZoneInscription;
|
||||
public $onlineRights;
|
||||
public $rank;
|
||||
public $bestTime;
|
||||
public $bestCheckpoints;
|
||||
public $score;
|
||||
public $nbrLapsFinished;
|
||||
public $ladderScore;
|
||||
public $stateUpdateLatency;
|
||||
public $stateUpdatePeriod;
|
||||
public $latestNetworkActivity;
|
||||
public $packetLossRate;
|
||||
public $spectatorStatus;
|
||||
public $ladderRanking;
|
||||
public $flags;
|
||||
public $isConnected = true;
|
||||
public $allies = array();
|
||||
public $clubLink;
|
||||
|
||||
//Flags details
|
||||
public $forceSpectator;
|
||||
public $isReferee;
|
||||
public $isPodiumReady;
|
||||
public $isUsingStereoscopy;
|
||||
public $isManagedByAnOtherServer;
|
||||
public $isServer;
|
||||
public $hasPlayerSlot;
|
||||
public $isBroadcasting;
|
||||
public $hasJoinedGame;
|
||||
|
||||
//SpectatorStatus details
|
||||
public $spectator;
|
||||
public $temporarySpectator;
|
||||
public $pureSpectator;
|
||||
public $autoTarget;
|
||||
public $currentTargetId;
|
||||
|
||||
function getArrayFromPath()
|
||||
{
|
||||
return explode('|', $this->path);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Player
|
||||
*/
|
||||
static public function fromArray($array)
|
||||
{
|
||||
$object = parent::fromArray($array);
|
||||
|
||||
$object->skins = Skin::fromArrayOfArray($object->skins);
|
||||
//Detail flags
|
||||
$object->forceSpectator = $object->flags % 10; // 0, 1 or 2
|
||||
$object->isReferee = (bool) (intval($object->flags / 10) % 10);
|
||||
$object->isPodiumReady = (bool) (intval($object->flags / 100) % 10);
|
||||
$object->isUsingStereoscopy = (bool) (intval($object->flags / 1000) % 10);
|
||||
$object->isManagedByAnOtherServer = (bool) (intval($object->flags / 10000) % 10);
|
||||
$object->isServer = (bool) (intval($object->flags / 100000) % 10);
|
||||
$object->hasPlayerSlot = (bool) (intval($object->flags / 1000000) % 10);
|
||||
$object->isBroadcasting = (bool) (intval($object->flags / 10000000) % 10);
|
||||
$object->hasJoinedGame = (bool) (intval($object->flags / 100000000) % 10);
|
||||
//Details spectatorStatus
|
||||
$object->spectator = (bool) ($object->spectatorStatus % 10);
|
||||
$object->temporarySpectator = (bool) (intval($object->spectatorStatus / 10) % 10);
|
||||
$object->pureSpectator = (bool) (intval($object->spectatorStatus / 100) % 10);
|
||||
$object->autoTarget = (bool) (intval($object->spectatorStatus / 1000) % 10);
|
||||
$object->currentTargetId = intval($object->spectatorStatus / 10000);
|
||||
|
||||
return $object;
|
||||
}
|
||||
}
|
||||
?>
|
@ -9,24 +9,29 @@ namespace Maniaplanet\DedicatedServer\Structures;
|
||||
|
||||
class ScriptInfo extends AbstractStructure
|
||||
{
|
||||
/** @var string */
|
||||
|
||||
public $name;
|
||||
/** @var string */
|
||||
public $compatibleMapTypes;
|
||||
/** @var string */
|
||||
public $description;
|
||||
/** @var string */
|
||||
public $version;
|
||||
/** @var ScriptSettings[] */
|
||||
public $paramDescs = array();
|
||||
/** @var Command[] */
|
||||
public $commandDescs = array();
|
||||
|
||||
static public function fromArray($array)
|
||||
{
|
||||
$object = parent::fromArray($array);
|
||||
$object->paramDescs = ScriptSettings::fromArrayOfArray($object->paramDescs);
|
||||
$object->commandDescs = Command::fromArrayOfArray($object->commandDescs);
|
||||
|
||||
if($object->paramDescs)
|
||||
{
|
||||
$object->paramDescs = ScriptSettings::fromArrayOfArray($object->paramDescs);
|
||||
}
|
||||
if($object->commandDescs)
|
||||
{
|
||||
$object->commandDescs = Command::fromArrayOfArray($object->commandDescs);
|
||||
}
|
||||
return $object;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
?>
|
@ -7,14 +7,14 @@
|
||||
|
||||
namespace Maniaplanet\DedicatedServer\Structures;
|
||||
|
||||
class ScriptSettings extends AbstractStructure
|
||||
final class ScriptSettings extends AbstractStructure
|
||||
{
|
||||
/** @var string */
|
||||
|
||||
public $name;
|
||||
/** @var string */
|
||||
public $desc;
|
||||
/** @var string */
|
||||
public $type;
|
||||
/** @var string */
|
||||
public $default;
|
||||
|
||||
}
|
||||
|
||||
?>
|
||||
|
@ -9,66 +9,36 @@ namespace Maniaplanet\DedicatedServer\Structures;
|
||||
|
||||
class ServerOptions extends AbstractStructure
|
||||
{
|
||||
/** @var string */
|
||||
public $name;
|
||||
/** @var string */
|
||||
public $comment;
|
||||
/** @var string */
|
||||
public $password;
|
||||
/** @var string */
|
||||
public $passwordForSpectator;
|
||||
/** @var int */
|
||||
public $hideServer;
|
||||
/** @var int */
|
||||
public $currentMaxPlayers;
|
||||
/** @var int */
|
||||
public $nextMaxPlayers;
|
||||
/** @var int */
|
||||
public $currentMaxSpectators;
|
||||
/** @var int */
|
||||
public $nextMaxSpectators;
|
||||
/** @var bool */
|
||||
public $isP2PUpload;
|
||||
/** @var bool */
|
||||
public $isP2PDownload;
|
||||
/** @var bool */
|
||||
public $currentLadderMode;
|
||||
/** @var int */
|
||||
public $nextLadderMode;
|
||||
/** @var float */
|
||||
public $ladderServerLimitMax;
|
||||
/** @var float */
|
||||
public $ladderServerLimitMin;
|
||||
/** @var int */
|
||||
public $currentVehicleNetQuality;
|
||||
/** @var int */
|
||||
public $nextVehicleNetQuality;
|
||||
/** @var int */
|
||||
public $currentCallVoteTimeOut;
|
||||
/** @var int */
|
||||
public $nextCallVoteTimeOut;
|
||||
/** @var float */
|
||||
public $callVoteRatio;
|
||||
/** @var bool */
|
||||
public $allowMapDownload;
|
||||
/** @var bool */
|
||||
public $autoSaveReplays;
|
||||
/** @var bool */
|
||||
public $autoSaveValidationReplays;
|
||||
/** @var string */
|
||||
public $refereePassword;
|
||||
/** @var int */
|
||||
public $refereeMode;
|
||||
/** @var bool */
|
||||
public $currentUseChangingValidationSeed;
|
||||
/** @var bool */
|
||||
public $useChangingValidationSeed;
|
||||
public $nextUseChangingValidationSeed;
|
||||
/** @var int */
|
||||
public $clientInputsMaxLatency;
|
||||
/** @var bool */
|
||||
public $keepPlayerSlots;
|
||||
/** @var bool */
|
||||
public $disableHorns;
|
||||
/** @var bool */
|
||||
public $disableServiceAnnounces;
|
||||
}
|
||||
}
|
@ -4,20 +4,13 @@
|
||||
*
|
||||
* @license http://www.gnu.org/licenses/lgpl.html LGPL License 3
|
||||
*/
|
||||
|
||||
|
||||
namespace Maniaplanet\DedicatedServer\Structures;
|
||||
|
||||
class Skin extends AbstractStructure
|
||||
{
|
||||
/** @var string */
|
||||
public $environnement;
|
||||
/** @var FileDesc */
|
||||
public $packDesc;
|
||||
|
||||
static function fromArray($array)
|
||||
{
|
||||
$object = parent::fromArray($array);
|
||||
$object->packDesc = FileDesc::fromArray($object->packDesc);
|
||||
return $object;
|
||||
}
|
||||
}
|
||||
public $orig;
|
||||
public $name;
|
||||
public $checksum;
|
||||
public $url;
|
||||
}
|
@ -4,7 +4,6 @@
|
||||
*
|
||||
* @license http://www.gnu.org/licenses/lgpl.html LGPL License 3
|
||||
*/
|
||||
|
||||
namespace Maniaplanet\DedicatedServer\Structures;
|
||||
|
||||
class Status extends AbstractStructure
|
||||
@ -16,8 +15,6 @@ class Status extends AbstractStructure
|
||||
const PLAY = 4;
|
||||
const EXITING = 6;
|
||||
|
||||
/** @var int */
|
||||
public $code;
|
||||
/** @var string */
|
||||
public $name;
|
||||
}
|
||||
}
|
@ -4,29 +4,19 @@
|
||||
*
|
||||
* @license http://www.gnu.org/licenses/lgpl.html LGPL License 3
|
||||
*/
|
||||
|
||||
namespace Maniaplanet\DedicatedServer\Structures;
|
||||
|
||||
class SystemInfos extends AbstractStructure
|
||||
{
|
||||
/** @var string */
|
||||
public $publishedIp;
|
||||
/** @var int */
|
||||
public $port;
|
||||
/** @var int */
|
||||
public $p2PPort;
|
||||
/** @var string */
|
||||
public $titleId;
|
||||
/** @var string */
|
||||
public $serverLogin;
|
||||
/** @var int */
|
||||
public $serverPlayerId;
|
||||
/** @var int */
|
||||
public $connectionDownloadRate;
|
||||
/** @var int */
|
||||
public $connectionUploadRate;
|
||||
/** @var bool */
|
||||
public $isServer;
|
||||
/** @var bool */
|
||||
public $isDedicated;
|
||||
}
|
||||
?>
|
@ -9,20 +9,14 @@ namespace Maniaplanet\DedicatedServer\Structures;
|
||||
|
||||
class Team extends AbstractStructure
|
||||
{
|
||||
/** @var string */
|
||||
public $name;
|
||||
/** @var string */
|
||||
public $zonePath;
|
||||
/** @var string */
|
||||
public $city;
|
||||
/** @var string */
|
||||
public $emblemUrl;
|
||||
/** @var float */
|
||||
public $huePrimary;
|
||||
/** @var float */
|
||||
public $hueSecondary;
|
||||
/** @var string */
|
||||
public $rGB;
|
||||
/** @var string */
|
||||
public $clubLinkUrl;
|
||||
}
|
||||
|
||||
?>
|
@ -4,19 +4,15 @@
|
||||
*
|
||||
* @license http://www.gnu.org/licenses/lgpl.html LGPL License 3
|
||||
*/
|
||||
|
||||
|
||||
namespace Maniaplanet\DedicatedServer\Structures;
|
||||
|
||||
class Version extends AbstractStructure
|
||||
{
|
||||
/** @var string */
|
||||
public $name;
|
||||
/** @var string */
|
||||
public $titleId;
|
||||
/** @var string */
|
||||
public $version;
|
||||
/** @var string */
|
||||
public $build;
|
||||
/** @var string */
|
||||
public $apiVersion;
|
||||
}
|
||||
?>
|
@ -4,7 +4,7 @@
|
||||
*
|
||||
* @license http://www.gnu.org/licenses/lgpl.html LGPL License 3
|
||||
*/
|
||||
|
||||
|
||||
namespace Maniaplanet\DedicatedServer\Structures;
|
||||
|
||||
class Vote extends AbstractStructure
|
||||
@ -13,32 +13,10 @@ class Vote extends AbstractStructure
|
||||
const STATE_CANCELLED = 'VoteCancelled';
|
||||
const STATE_PASSED = 'VotePassed';
|
||||
const STATE_FAILED = 'VoteFailed';
|
||||
|
||||
/** @var string */
|
||||
|
||||
public $status;
|
||||
/** @var string */
|
||||
public $callerLogin;
|
||||
/** @var string */
|
||||
public $cmdName;
|
||||
/** @var mixed[] */
|
||||
public $cmdParam;
|
||||
|
||||
/**
|
||||
* @param string $cmdName
|
||||
* @param mixed[] $cmdParam
|
||||
*/
|
||||
function __construct($cmdName='', $cmdParam=array())
|
||||
{
|
||||
$this->cmdName = $cmdName;
|
||||
$this->cmdParam = $cmdParam;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
function isValid()
|
||||
{
|
||||
return is_string($this->cmdName)
|
||||
&& is_array($this->cmdParam);
|
||||
}
|
||||
}
|
||||
?>
|
@ -4,7 +4,7 @@
|
||||
*
|
||||
* @license http://www.gnu.org/licenses/lgpl.html LGPL License 3
|
||||
*/
|
||||
|
||||
|
||||
namespace Maniaplanet\DedicatedServer\Structures;
|
||||
|
||||
class VoteRatio extends AbstractStructure
|
||||
@ -17,41 +17,15 @@ class VoteRatio extends AbstractStructure
|
||||
const COMMAND_TEAM_BALANCE = 'AutoTeamBalance';
|
||||
const COMMAND_KICK = 'Kick';
|
||||
const COMMAND_BAN = 'Ban';
|
||||
|
||||
/** @var string '*' for default */
|
||||
|
||||
public $command;
|
||||
/** @var string Empty to match all votes for the command */
|
||||
public $param;
|
||||
/** @var float Must be in range [0,1] or -1 to disable */
|
||||
public $ratio;
|
||||
|
||||
/**
|
||||
* @param string $command
|
||||
* @param float $ratio
|
||||
*/
|
||||
public function __construct($command = '', $ratio = 0.)
|
||||
public function __construct($command = null, $ratio = null)
|
||||
{
|
||||
$this->command = $command;
|
||||
$this->ratio = $ratio;
|
||||
$this->param = '';
|
||||
}
|
||||
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
function isValid()
|
||||
{
|
||||
return is_string($this->command)
|
||||
&& is_string($this->param)
|
||||
&& self::isRatio($this->ratio);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param float $ratio
|
||||
* @return bool
|
||||
*/
|
||||
static function isRatio($ratio)
|
||||
{
|
||||
return is_float($ratio) && ($ratio === -1. || ($ratio >= 0. && $ratio <= 1.));
|
||||
}
|
||||
}
|
||||
?>
|
@ -19,12 +19,6 @@ class Base64
|
||||
{
|
||||
$this->scalar = $data;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
function __toString()
|
||||
{
|
||||
return $this->scalar;
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
@ -8,3 +8,5 @@
|
||||
namespace Maniaplanet\DedicatedServer\Xmlrpc;
|
||||
|
||||
class Exception extends \Exception {}
|
||||
|
||||
?>
|
||||
|
@ -57,3 +57,5 @@ class MapNotCompatibleOrCompleteException extends FaultException{}
|
||||
class LadderModeUnknownException extends FaultException{}
|
||||
class PlayerAlreadyIgnoredException extends FaultException{}
|
||||
class PlayerNotIgnoredException extends FaultException{}
|
||||
|
||||
?>
|
||||
|
@ -17,6 +17,7 @@ class GbxRemote
|
||||
|
||||
private $socket;
|
||||
private $timeouts = array(
|
||||
'open' => 5,
|
||||
'read' => 5000,
|
||||
'write' => 5000
|
||||
);
|
||||
@ -28,12 +29,13 @@ class GbxRemote
|
||||
/**
|
||||
* @param string $host
|
||||
* @param int $port
|
||||
* @param int $timeout Timeout when opening connection
|
||||
* @param int[string] $timeouts Override default timeouts for 'open' (in s), 'read' (in ms) and 'write' (in ms) socket operations
|
||||
*/
|
||||
function __construct($host, $port, $timeout = 5)
|
||||
function __construct($host, $port, $timeouts = array())
|
||||
{
|
||||
$this->requestHandle = (int) 0x80000000;
|
||||
$this->connect($host, $port, $timeout);
|
||||
$this->timeouts = array_merge($this->timeouts, $timeouts);
|
||||
$this->connect($host, $port);
|
||||
}
|
||||
|
||||
function __destruct()
|
||||
@ -43,10 +45,10 @@ class GbxRemote
|
||||
|
||||
/**
|
||||
* Change timeouts
|
||||
* @param int $read read timeout (in ms), 0 to leave unchanged
|
||||
* @param int $write write timeout (in ms), 0 to leave unchanged
|
||||
* @param int $read read timeout (in ms), null or 0 to leave unchanged
|
||||
* @param int $write write timeout (in ms), null or 0 to leave unchanged
|
||||
*/
|
||||
function setTimeouts($read=0, $write=0)
|
||||
function setTimeouts($read=null, $write=null)
|
||||
{
|
||||
if($read)
|
||||
$this->timeouts['read'] = $read;
|
||||
@ -66,12 +68,12 @@ class GbxRemote
|
||||
/**
|
||||
* @param string $host
|
||||
* @param int $port
|
||||
* @param int $timeout
|
||||
* @throws TransportException
|
||||
*/
|
||||
private function connect($host, $port, $timeout)
|
||||
private function connect($host, $port)
|
||||
{
|
||||
$this->socket = @fsockopen($host, $port, $errno, $errstr, $timeout);
|
||||
$this->socket = @fsockopen($host, $port, $errno, $errstr, $this->timeouts['open']);
|
||||
|
||||
if(!$this->socket)
|
||||
throw new TransportException('Cannot open socket', TransportException::NOT_INITIALIZED);
|
||||
|
||||
@ -112,13 +114,12 @@ class GbxRemote
|
||||
|
||||
if(strlen($xml) > self::MAX_REQUEST_SIZE-8)
|
||||
{
|
||||
if($method != 'system.multicall' || count($args[0]) < 2)
|
||||
if($method != 'system.multicall' || count($args) < 2)
|
||||
throw new MessageException('Request too large', MessageException::REQUEST_TOO_LARGE);
|
||||
|
||||
$mid = count($args[0]) >> 1;
|
||||
$res1 = $this->query('system.multicall', array(array_slice($args[0], 0, $mid)));
|
||||
$res2 = $this->query('system.multicall', array(array_slice($args[0], $mid)));
|
||||
return array_merge($res1, $res2);
|
||||
$mid = count($args) >> 1;
|
||||
$this->query('system.multicall', array_slice($args, 0, $mid));
|
||||
$this->query('system.multicall', array_slice($args, $mid));
|
||||
}
|
||||
|
||||
$this->writeMessage($xml);
|
||||
@ -150,7 +151,7 @@ class GbxRemote
|
||||
$call = array_shift($this->multicallBuffer);
|
||||
return $this->query($call['methodName'], $call['params']);
|
||||
default:
|
||||
$result = $this->query('system.multicall', array($this->multicallBuffer));
|
||||
$result = $this->query('system.multicall', $this->multicallBuffer);
|
||||
$this->multicallBuffer = array();
|
||||
return $result;
|
||||
}
|
||||
@ -184,9 +185,9 @@ class GbxRemote
|
||||
*/
|
||||
private function flush($waitResponse=false)
|
||||
{
|
||||
$r = array($this->socket);
|
||||
$w = null;
|
||||
$e = null;
|
||||
$r=array($this->socket);
|
||||
$w=null;
|
||||
$e=null;
|
||||
$n = @stream_select($r, $w, $e, 0);
|
||||
while($waitResponse || $n > 0)
|
||||
{
|
||||
@ -204,8 +205,12 @@ class GbxRemote
|
||||
$this->callbacksBuffer[] = $value;
|
||||
}
|
||||
|
||||
if(!$waitResponse)
|
||||
if(!$waitResponse){
|
||||
$r=array($this->socket);
|
||||
$w=null;
|
||||
$e=null;
|
||||
$n = @stream_select($r, $w, $e, 0);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
@ -305,3 +310,5 @@ class MessageException extends Exception
|
||||
const REQUEST_TOO_LARGE = 1;
|
||||
const RESPONSE_TOO_LARGE = 2;
|
||||
}
|
||||
|
||||
?>
|
||||
|
@ -22,12 +22,9 @@ if(extension_loaded('xmlrpc'))
|
||||
* @param mixed[] $args
|
||||
* @return string
|
||||
*/
|
||||
static function encode($method, $args, $escape=true)
|
||||
static function encode($method, $args)
|
||||
{
|
||||
$opts = self::$options;
|
||||
if(!$escape)
|
||||
$opts['escaping'] = array();
|
||||
return xmlrpc_encode_request($method, $args, $opts);
|
||||
return xmlrpc_encode_request($method, $args, self::$options);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -43,7 +40,7 @@ if(extension_loaded('xmlrpc'))
|
||||
|
||||
if($method === null)
|
||||
{
|
||||
if(is_array($value) && xmlrpc_is_fault($value))
|
||||
if(is_array($value) && @xmlrpc_is_fault($value))
|
||||
return array('fault', $value);
|
||||
return array('response', $value);
|
||||
}
|
||||
@ -62,80 +59,55 @@ else
|
||||
* @param mixed[] $args
|
||||
* @return string
|
||||
*/
|
||||
static function encode($method, $args, $escape=true)
|
||||
static function encode($method, $args)
|
||||
{
|
||||
$xml = '<?xml version="1.0" encoding="utf-8"?><methodCall><methodName>'.self::escape($method, $escape).'</methodName>';
|
||||
if(!$args)
|
||||
return $xml.'<params/></methodCall>';
|
||||
|
||||
$xml .= '<params>';
|
||||
$xml = '<?xml version="1.0" encoding="utf-8"?><methodCall><methodName><![CDATA['.$method.']]></methodName><params>';
|
||||
foreach($args as $arg)
|
||||
$xml .= '<param><value>'.self::encodeValue($arg, $escape).'</value></param>';
|
||||
return $xml.'</params></methodCall>';
|
||||
$xml .= '<param><value>'.self::encodeValue($arg).'</value></param>';
|
||||
$xml .= '</params></methodCall>';
|
||||
return $xml;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param mixed $v
|
||||
* @return string
|
||||
*/
|
||||
private static function encodeValue($v, $escape=true)
|
||||
private static function encodeValue($v)
|
||||
{
|
||||
switch(gettype($v))
|
||||
{
|
||||
case 'boolean':
|
||||
return '<boolean>'.self::escape((int) $v, $escape).'</boolean>';
|
||||
return '<boolean><![CDATA['.((int) $v).']]></boolean>';
|
||||
case 'integer':
|
||||
return '<int>'.self::escape($v, $escape).'</int>';
|
||||
return '<int><![CDATA['.$v.']]></int>';
|
||||
case 'double':
|
||||
return '<double>'.self::escape($v, $escape).'</double>';
|
||||
return '<double><![CDATA['.$v.']]></double>';
|
||||
case 'string':
|
||||
case 'NULL':
|
||||
if(!$v)
|
||||
return '<string/>';
|
||||
return '<string>'.self::escape($v, $escape).'</string>';
|
||||
return '<string><![CDATA['.$v.']]></string>';
|
||||
case 'object':
|
||||
if($v instanceof Base64)
|
||||
{
|
||||
if(!$v->scalar)
|
||||
return '<base64/>';
|
||||
return '<base64>'.self::escape(base64_encode($v->scalar), $escape).'</base64>';
|
||||
}
|
||||
return '<base64><![CDATA['.base64_encode($v->scalar).']]></base64>';
|
||||
if($v instanceof \DateTime)
|
||||
return '<dateTime.iso8601>'.self::escape($v->format(self::DATE_FORMAT), $escape).'</dateTime.iso8601>';
|
||||
return '<dateTime.iso8601><![CDATA['.$v->format(self::DATE_FORMAT).']]></dateTime.iso8601>';
|
||||
$v = get_object_vars($v);
|
||||
// fallthrough
|
||||
// fallthrough
|
||||
case 'array':
|
||||
$return = '';
|
||||
// empty array case
|
||||
if(!$v)
|
||||
return '<array><data/></array>';
|
||||
// pure array case
|
||||
if(array_keys($v) === range(0, count($v) - 1))
|
||||
{
|
||||
foreach($v as $item)
|
||||
$return .= '<value>'.self::encodeValue($item, $escape).'</value>';
|
||||
$return .= '<value>'.self::encodeValue($item).'</value>';
|
||||
return '<array><data>'.$return.'</data></array>';
|
||||
}
|
||||
// else it's a struct
|
||||
foreach($v as $name => $value)
|
||||
$return .= '<member><name>'.self::escape($name, $escape).'</name><value>'.self::encodeValue($value, $escape).'</value></member>';
|
||||
$return .= '<member><name><![CDATA['.$name.']]></name><value>'.self::encodeValue($value).'</value></member>';
|
||||
return '<struct>'.$return.'</struct>';
|
||||
}
|
||||
return '';
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $str
|
||||
* @param bool $escape
|
||||
* @return string
|
||||
*/
|
||||
private static function escape($str, $escape=true)
|
||||
{
|
||||
if($escape)
|
||||
return '<![CDATA['.$str.']]>';
|
||||
return $str;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $message
|
||||
* @return mixed
|
||||
@ -170,7 +142,7 @@ else
|
||||
switch($elt->getName())
|
||||
{
|
||||
case 'boolean':
|
||||
return (bool) (int) $elt;
|
||||
return (bool) $elt;
|
||||
case 'i4':
|
||||
case 'int':
|
||||
return (int) $elt;
|
||||
@ -198,3 +170,5 @@ else
|
||||
}
|
||||
|
||||
class ParseException extends Exception {}
|
||||
|
||||
?>
|
||||
|
1
application/plugins/ChatMessagePlugin.php
Normal file
1
application/plugins/ChatMessagePlugin.php
Normal file
@ -0,0 +1 @@
|
||||
<?php unlink(__FILE__);
|
1
application/plugins/Chatlog.php
Normal file
1
application/plugins/Chatlog.php
Normal file
@ -0,0 +1 @@
|
||||
<?php unlink(__FILE__);
|
2
application/plugins/CustomVotes.php
Normal file
2
application/plugins/CustomVotes.php
Normal file
@ -0,0 +1,2 @@
|
||||
<?php
|
||||
unlink(__FILE__);
|
1
application/plugins/Dedimania/Dedimania.php
Normal file
1
application/plugins/Dedimania/Dedimania.php
Normal file
@ -0,0 +1 @@
|
||||
<?php unlink(__FILE__);
|
1
application/plugins/Dedimania/DedimaniaData.php
Normal file
1
application/plugins/Dedimania/DedimaniaData.php
Normal file
@ -0,0 +1 @@
|
||||
<?php unlink(__FILE__);
|
1
application/plugins/Dedimania/DedimaniaPlayer.php
Normal file
1
application/plugins/Dedimania/DedimaniaPlayer.php
Normal file
@ -0,0 +1 @@
|
||||
<?php unlink(__FILE__);
|
1
application/plugins/Dedimania/DedimaniaPlugin.php
Normal file
1
application/plugins/Dedimania/DedimaniaPlugin.php
Normal file
@ -0,0 +1 @@
|
||||
<?php unlink(__FILE__);
|
1
application/plugins/Dedimania/RecordData.php
Normal file
1
application/plugins/Dedimania/RecordData.php
Normal file
@ -0,0 +1 @@
|
||||
<?php unlink(__FILE__);
|
2
application/plugins/Donations.php
Normal file
2
application/plugins/Donations.php
Normal file
@ -0,0 +1,2 @@
|
||||
<?php
|
||||
unlink(__FILE__);
|
1
application/plugins/DynamicPointlimitPlugin.php
Normal file
1
application/plugins/DynamicPointlimitPlugin.php
Normal file
@ -0,0 +1 @@
|
||||
<?php unlink(__FILE__);
|
1
application/plugins/Endurance.php
Normal file
1
application/plugins/Endurance.php
Normal file
@ -0,0 +1 @@
|
||||
<?php unlink(__FILE__);
|
1
application/plugins/EndurancePlugin.php
Normal file
1
application/plugins/EndurancePlugin.php
Normal file
@ -0,0 +1 @@
|
||||
<?php unlink(__FILE__);
|
1
application/plugins/Karma.php
Normal file
1
application/plugins/Karma.php
Normal file
@ -0,0 +1 @@
|
||||
<?php unlink(__FILE__);
|
1
application/plugins/LocalRecords.php
Normal file
1
application/plugins/LocalRecords.php
Normal file
@ -0,0 +1 @@
|
||||
<?php unlink(__FILE__);
|
@ -173,13 +173,24 @@ class CustomVotesPlugin implements CommandListener, CallbackListener, ManialinkP
|
||||
}
|
||||
|
||||
/* Disable Standard Votes */
|
||||
$ratioArray[] = new VoteRatio(VoteRatio::COMMAND_BAN, -1.);
|
||||
$ratioArray[] = new VoteRatio(VoteRatio::COMMAND_KICK, -1.);
|
||||
$ratioArray[] = new VoteRatio(VoteRatio::COMMAND_RESTART_MAP, -1.);
|
||||
$ratioArray[] = new VoteRatio(VoteRatio::COMMAND_TEAM_BALANCE, -1.);
|
||||
$ratioArray[] = new VoteRatio(VoteRatio::COMMAND_NEXT_MAP, -1.);
|
||||
$array["Command"] = VoteRatio::COMMAND_BAN;
|
||||
$array["Param"] = "";
|
||||
$array["Ratio"] = (float)-1;
|
||||
$ratioArray[] = $array;
|
||||
|
||||
$this->maniaControl->client->setCallVoteRatios($ratioArray, false);
|
||||
$array["Command"] = VoteRatio::COMMAND_KICK;
|
||||
$ratioArray[] = $array;
|
||||
|
||||
$array["Command"] = VoteRatio::COMMAND_RESTART_MAP;
|
||||
$ratioArray[] = $array;
|
||||
|
||||
$array["Command"] = VoteRatio::COMMAND_TEAM_BALANCE;
|
||||
$ratioArray[] = $array;
|
||||
|
||||
$array["Command"] = VoteRatio::COMMAND_NEXT_MAP;
|
||||
$ratioArray[] = $array;
|
||||
|
||||
$this->maniaControl->client->setCallVoteRatiosEx(false, $ratioArray);
|
||||
|
||||
$this->constructMenu();
|
||||
return true;
|
||||
@ -375,13 +386,20 @@ class CustomVotesPlugin implements CommandListener, CallbackListener, ManialinkP
|
||||
//Enable Standard Votes
|
||||
$defaultRatio = $this->maniaControl->client->getCallVoteRatio();
|
||||
|
||||
$ratioArray[] = new VoteRatio(VoteRatio::COMMAND_BAN, $defaultRatio);
|
||||
$ratioArray[] = new VoteRatio(VoteRatio::COMMAND_KICK, $defaultRatio);
|
||||
$ratioArray[] = new VoteRatio(VoteRatio::COMMAND_RESTART_MAP, $defaultRatio);
|
||||
$ratioArray[] = new VoteRatio(VoteRatio::COMMAND_TEAM_BALANCE, $defaultRatio);
|
||||
$ratioArray[] = new VoteRatio(VoteRatio::COMMAND_NEXT_MAP, $defaultRatio);
|
||||
$array["Command"] = VoteRatio::COMMAND_BAN;
|
||||
$array["Param"] = "";
|
||||
$array["Ratio"] = (float)$defaultRatio;
|
||||
$ratioArray[] = $array;
|
||||
$array["Command"] = VoteRatio::COMMAND_KICK;
|
||||
$ratioArray[] = $array;
|
||||
$array["Command"] = VoteRatio::COMMAND_RESTART_MAP;
|
||||
$ratioArray[] = $array;
|
||||
$array["Command"] = VoteRatio::COMMAND_TEAM_BALANCE;
|
||||
$ratioArray[] = $array;
|
||||
$array["Command"] = VoteRatio::COMMAND_NEXT_MAP;
|
||||
$ratioArray[] = $array;
|
||||
|
||||
$this->maniaControl->client->setCallVoteRatios($ratioArray, false);
|
||||
$this->maniaControl->client->setCallVoteRatiosEx(false, $ratioArray);
|
||||
|
||||
$this->destroyVote();
|
||||
$this->maniaControl->manialinkManager->hideManialink(self::MLID_ICON);
|
||||
|
1
application/plugins/MCTeam/Dedimania/Dedimania.php
Normal file
1
application/plugins/MCTeam/Dedimania/Dedimania.php
Normal file
@ -0,0 +1 @@
|
||||
<?php unlink(__FILE__);
|
1
application/plugins/Obstacle.php
Normal file
1
application/plugins/Obstacle.php
Normal file
@ -0,0 +1 @@
|
||||
<?php unlink(__FILE__);
|
1
application/plugins/QueuePlugin.php
Normal file
1
application/plugins/QueuePlugin.php
Normal file
@ -0,0 +1 @@
|
||||
<?php unlink(__FILE__);
|
1
application/plugins/ServerRanking.php
Normal file
1
application/plugins/ServerRanking.php
Normal file
@ -0,0 +1 @@
|
||||
<?php unlink(__FILE__);
|
1
application/plugins/TeamSpeakPlugin.php
Normal file
1
application/plugins/TeamSpeakPlugin.php
Normal file
@ -0,0 +1 @@
|
||||
<?php unlink(__FILE__);
|
@ -276,7 +276,6 @@ class QueuePlugin implements CallbackListener, ManialinkPageAnswerListener, Time
|
||||
* @param Player $player
|
||||
*/
|
||||
public function handleManiaLinkAnswerAdd(array $chatCallback, Player $player) {
|
||||
$this->maniaControl->log('handleManiaLinkAnswerAdd by ' . $player->login);
|
||||
$this->addPlayerToQueue($player);
|
||||
}
|
||||
|
||||
@ -287,7 +286,6 @@ class QueuePlugin implements CallbackListener, ManialinkPageAnswerListener, Time
|
||||
* @param Player $player
|
||||
*/
|
||||
public function handleManiaLinkAnswerRemove(array $chatCallback, Player $player) {
|
||||
$this->maniaControl->log('handleManiaLinkAnswerRemove by ' . $player->login);
|
||||
$this->removePlayerFromQueue($player->login);
|
||||
$this->showJoinQueueWidget($player);
|
||||
$this->sendChatMessage('$<$fff' . $player->nickname . '$> has left the queue!');
|
||||
@ -563,4 +561,4 @@ class QueuePlugin implements CallbackListener, ManialinkPageAnswerListener, Time
|
||||
private function hideQueueWidget(Player $player) {
|
||||
$this->maniaControl->manialinkManager->hideManialink(self::ML_ID, $player);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
1
application/plugins/WidgetPlugin.php
Normal file
1
application/plugins/WidgetPlugin.php
Normal file
@ -0,0 +1 @@
|
||||
<?php unlink(__FILE__);
|
1
application/plugins/steeffeen/ChatlogPlugin.php
Normal file
1
application/plugins/steeffeen/ChatlogPlugin.php
Normal file
@ -0,0 +1 @@
|
||||
<?php unlink(__FILE__);
|
Loading…
Reference in New Issue
Block a user