improved map restart param parsing
This commit is contained in:
parent
e25b352a7a
commit
6aeea15621
@ -45,6 +45,9 @@ class LibXmlRpcCallbacks implements CallbackListener {
|
||||
break;
|
||||
case 'BeginMap':
|
||||
case 'LibXmlRpc_BeginMap':
|
||||
if (!isset($data[2])) {
|
||||
$data[2] = 'False';
|
||||
}
|
||||
$this->maniaControl->mapManager->handleScriptBeginMap($data[1], $data[2]);
|
||||
break;
|
||||
case 'LibXmlRpc_BeginSubmatch':
|
||||
|
@ -12,6 +12,7 @@ use ManiaControl\ManiaExchange\ManiaExchangeList;
|
||||
use ManiaControl\ManiaExchange\ManiaExchangeManager;
|
||||
use ManiaControl\ManiaExchange\MXMapInfo;
|
||||
use ManiaControl\Players\Player;
|
||||
use ManiaControl\Utils\Formatter;
|
||||
use Maniaplanet\DedicatedServer\InvalidArgumentException;
|
||||
use Maniaplanet\DedicatedServer\Xmlrpc\Exception;
|
||||
use Maniaplanet\DedicatedServer\Xmlrpc\FileException;
|
||||
@ -245,7 +246,9 @@ class MapManager implements CallbackListener {
|
||||
public function addMapFromMx($mapId, $login, $update = false) {
|
||||
if (is_numeric($mapId)) {
|
||||
// Check if map exists
|
||||
$this->maniaControl->mapManager->mxManager->fetchMapInfo($mapId, function (MXMapInfo $mapInfo = null) use (&$login, &$update) {
|
||||
$this->maniaControl->mapManager->mxManager->fetchMapInfo($mapId, function (MXMapInfo $mapInfo = null) use (
|
||||
&$login, &$update
|
||||
) {
|
||||
if (!$mapInfo || !isset($mapInfo->uploaded)) {
|
||||
// Invalid id
|
||||
$this->maniaControl->chat->sendError('Invalid MX-Id!', $login);
|
||||
@ -253,7 +256,9 @@ class MapManager implements CallbackListener {
|
||||
}
|
||||
|
||||
// Download the file
|
||||
$this->maniaControl->fileReader->loadFile($mapInfo->downloadurl, function ($file, $error) use (&$login, &$mapInfo, &$update) {
|
||||
$this->maniaControl->fileReader->loadFile($mapInfo->downloadurl, function ($file, $error) use (
|
||||
&$login, &$mapInfo, &$update
|
||||
) {
|
||||
if (!$file || $error) {
|
||||
// Download error
|
||||
$this->maniaControl->chat->sendError("Download failed: '{$error}'!", $login);
|
||||
@ -643,10 +648,10 @@ class MapManager implements CallbackListener {
|
||||
* Handle Script BeginMap callback
|
||||
*
|
||||
* @param string $mapUid
|
||||
* @param bool $restart
|
||||
* @param string $restart
|
||||
*/
|
||||
public function handleScriptBeginMap($mapUid, $restart) {
|
||||
$this->beginMap($mapUid, strtolower($restart) === 'true' ? true : false);
|
||||
$this->beginMap($mapUid, Formatter::parseBoolean($restart));
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -168,8 +168,7 @@ abstract class Formatter {
|
||||
if (is_string($value)) {
|
||||
$value = strtolower($value);
|
||||
}
|
||||
$bool = filter_var($value, FILTER_VALIDATE_BOOLEAN);
|
||||
return $bool;
|
||||
return filter_var($value, FILTER_VALIDATE_BOOLEAN);
|
||||
}
|
||||
|
||||
/**
|
||||
|
Loading…
Reference in New Issue
Block a user