From bdee746e4615ad941c7c0543608d774900c8d184 Mon Sep 17 00:00:00 2001 From: "Dylan K. Taylor" Date: Sat, 16 Sep 2017 11:22:58 +0100 Subject: [PATCH 1/5] Automatically enable ANSI colours on Windows versions that support it Note that stream_isatty() and sapi_windows_vt100_support() are ONLY defined on PHP 7.2, and the latter is only available on Windows. --- src/pocketmine/utils/Terminal.php | 8 +++++++- start.ps1 | 2 +- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/src/pocketmine/utils/Terminal.php b/src/pocketmine/utils/Terminal.php index 3fec7fcb0f..0b53c2ef3e 100644 --- a/src/pocketmine/utils/Terminal.php +++ b/src/pocketmine/utils/Terminal.php @@ -57,7 +57,13 @@ abstract class Terminal{ if(isset($opts["disable-ansi"])){ self::$formattingCodes = false; }else{ - self::$formattingCodes = ((Utils::getOS() !== "win" and getenv("TERM") != "" and (!function_exists("posix_ttyname") or !defined("STDOUT") or posix_ttyname(STDOUT) !== false)) or isset($opts["enable-ansi"])); + self::$formattingCodes = (isset($opts["enable-ansi"]) or ( //user explicitly told us to enable ANSI + stream_isatty(STDOUT) and //STDOUT isn't being piped + ( + getenv('TERM') !== false or //Console says it supports colours + (function_exists('sapi_windows_vt100_support') and sapi_windows_vt100_support(STDOUT)) //we're on windows and have vt100 support + ) + )); } } diff --git a/start.ps1 b/start.ps1 index 9c0cf318f4..b7f1890ab9 100644 --- a/start.ps1 +++ b/start.ps1 @@ -25,7 +25,7 @@ if(Test-Path "PocketMine-MP.phar"){ } function StartServer{ - $command = "powershell " + $binary + " " + $file + " --enable-ansi " + $extraPocketMineArgs + $command = "powershell " + $binary + " " + $file + " " + $extraPocketMineArgs iex $command } From a99eee9def3a09a06fad6f7f10361124fcb85c20 Mon Sep 17 00:00:00 2001 From: "Dylan K. Taylor" Date: Sun, 17 Sep 2017 20:01:11 +0100 Subject: [PATCH 2/5] Removed redundant assignment --- src/pocketmine/Player.php | 1 - 1 file changed, 1 deletion(-) diff --git a/src/pocketmine/Player.php b/src/pocketmine/Player.php index b91fc5c8ff..130acb3b0a 100644 --- a/src/pocketmine/Player.php +++ b/src/pocketmine/Player.php @@ -642,7 +642,6 @@ class Player extends Human implements CommandSender, ChunkLoader, IPlayer{ $this->loaderId = Level::generateChunkLoaderId($this); $this->chunksPerTick = (int) $this->server->getProperty("chunk-sending.per-tick", 4); $this->spawnThreshold = (int) (($this->server->getProperty("chunk-sending.spawn-radius", 4) ** 2) * M_PI); - $this->spawnPosition = null; $this->gamemode = $this->server->getGamemode(); $this->setLevel($this->server->getDefaultLevel()); $this->boundingBox = new AxisAlignedBB(0, 0, 0, 0, 0, 0); From 1e4cbb0dd9615e93e41af5696a23264193c3e885 Mon Sep 17 00:00:00 2001 From: "Dylan K. Taylor" Date: Mon, 18 Sep 2017 09:34:00 +0100 Subject: [PATCH 3/5] RakLibInterface: move array initialization to default value doesn't make sense to do this in the ctor when all the others are normal --- src/pocketmine/network/mcpe/RakLibInterface.php | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/pocketmine/network/mcpe/RakLibInterface.php b/src/pocketmine/network/mcpe/RakLibInterface.php index 77d4146ce2..8d9b888b85 100644 --- a/src/pocketmine/network/mcpe/RakLibInterface.php +++ b/src/pocketmine/network/mcpe/RakLibInterface.php @@ -54,7 +54,7 @@ class RakLibInterface implements ServerInstance, AdvancedSourceInterface{ private $players = []; /** @var string[] */ - private $identifiers; + private $identifiers = []; /** @var int[] */ private $identifiersACK = []; @@ -63,9 +63,7 @@ class RakLibInterface implements ServerInstance, AdvancedSourceInterface{ private $interface; public function __construct(Server $server){ - $this->server = $server; - $this->identifiers = []; $this->rakLib = new RakLibServer($this->server->getLogger(), $this->server->getLoader(), $this->server->getPort(), $this->server->getIp() === "" ? "0.0.0.0" : $this->server->getIp(), false); $this->interface = new ServerHandler($this->rakLib, $this); From 3f56d6ddc8c4752776d6f06d07ec9a683cecae38 Mon Sep 17 00:00:00 2001 From: "Dylan K. Taylor" Date: Mon, 18 Sep 2017 09:42:25 +0100 Subject: [PATCH 4/5] RakLibInterface: removed useless needACK condition --- src/pocketmine/network/mcpe/RakLibInterface.php | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/src/pocketmine/network/mcpe/RakLibInterface.php b/src/pocketmine/network/mcpe/RakLibInterface.php index 8d9b888b85..216d8fa60f 100644 --- a/src/pocketmine/network/mcpe/RakLibInterface.php +++ b/src/pocketmine/network/mcpe/RakLibInterface.php @@ -211,13 +211,10 @@ class RakLibInterface implements ServerInstance, AdvancedSourceInterface{ if($packet instanceof BatchPacket){ if($needACK){ $pk = new EncapsulatedPacket(); + $pk->identifierACK = $this->identifiersACK[$identifier]++; $pk->buffer = $packet->buffer; $pk->reliability = $immediate ? PacketReliability::RELIABLE : PacketReliability::RELIABLE_ORDERED; $pk->orderChannel = 0; - - if($needACK === true){ - $pk->identifierACK = $this->identifiersACK[$identifier]++; - } }else{ if(!isset($packet->__encapsulatedPacket)){ $packet->__encapsulatedPacket = new CachedEncapsulatedPacket; From 1fd7f441b4bc935181484ac6564eafb95c4b0718 Mon Sep 17 00:00:00 2001 From: "Dylan K. Taylor" Date: Mon, 18 Sep 2017 10:14:24 +0100 Subject: [PATCH 5/5] Travis: use older version of pthreads master is broken - https://github.com/krakjoe/pthreads/issues/757 --- .travis.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index fd491e7aa4..3493d03052 100644 --- a/.travis.yml +++ b/.travis.yml @@ -6,8 +6,9 @@ php: before_script: # - pecl install channel://pecl.php.net/pthreads-3.1.6 - echo | pecl install channel://pecl.php.net/yaml-2.0.2 - - git clone https://github.com/krakjoe/pthreads.git --depth=1 + - git clone https://github.com/krakjoe/pthreads.git - cd pthreads + - git checkout caca8dc42a5d75ddfb39e6fd15337e87e967517e #master is broken - https://github.com/krakjoe/pthreads/issues/757 - phpize - ./configure - make