Added upload/download speed on title bar, referenced ChunkRequestTask

This commit is contained in:
Shoghi Cervantes 2014-07-11 02:23:40 +02:00
parent 756a8fead6
commit f2fa13119a
6 changed files with 22 additions and 6 deletions

View File

@ -502,6 +502,7 @@ class Player extends Human implements CommandSender, InventoryHolder, IPlayer{
$pk->chunkX = $x;
$pk->chunkZ = $z;
$this->dataPacket($pk);
$this->getLevel()->freeChunk($x, $z, $this);
unset($this->usedChunks[$index]);
}
unset($this->loadQueue[$index]);

View File

@ -1980,7 +1980,7 @@ class Server{
public function titleTick(){
if(defined("pocketmine\\DEBUG") and \pocketmine\DEBUG >= 0 and \pocketmine\ANSI === true){
echo "\x1b]0;PocketMine-MP " . $this->getPocketMineVersion() . " | Online " . count($this->players) . "/" . $this->getMaxPlayers() . " | RAM " . round((memory_get_usage() / 1024) / 1024, 2) . "/" . round((memory_get_usage(true) / 1024) / 1024, 2) . " MB | U -1 D -1 kB/s | TPS " . $this->getTicksPerSecond() . "\x07";
echo "\x1b]0;PocketMine-MP " . $this->getPocketMineVersion() . " | Online " . count($this->players) . "/" . $this->getMaxPlayers() . " | RAM " . round((memory_get_usage() / 1024) / 1024, 2) . "/" . round((memory_get_usage(true) / 1024) / 1024, 2) . " MB | U ". round($this->mainInterface->getUploadUsage() / 1024, 2) ." D ". round($this->mainInterface->getDownloadUsage() / 1024, 2) ." kB/s | TPS " . $this->getTicksPerSecond() . "\x07";
}
}

View File

@ -114,7 +114,7 @@ class ChunkRequestTask extends AsyncTask{
$this->setResult($ordered);
}
public function getColumn($data, $x, $z){
public function getColumn(&$data, $x, $z){
$i = ($z << 4) + $x;
$column = "";
for($y = 0; $y < 128; ++$y){
@ -123,7 +123,7 @@ class ChunkRequestTask extends AsyncTask{
return $column;
}
public function getHalfColumn($data, $x, $z){
public function getHalfColumn(&$data, $x, $z){
$i = ($z << 3) + ($x >> 1);
$column = "";
if(($x & 1) === 0){

View File

@ -99,6 +99,9 @@ class RakLibInterface implements ServerInstance, SourceInterface{
private $tickTask;
private $upload = 0;
private $download = 0;
public function __construct(Server $server){
$this->server = $server;
$this->identifers = new \SplObjectStorage();
@ -181,7 +184,19 @@ class RakLibInterface implements ServerInstance, SourceInterface{
}
public function handleOption($name, $value){
//TODO
if($name === "bandwidth"){
$v = unserialize($value);
$this->upload = $v["up"];
$this->download = $v["down"];
}
}
public function getUploadUsage(){
return $this->upload;
}
public function getDownloadUsage(){
return $this->download;
}
public function putPacket(Player $player, DataPacket $packet, $needACK = false, $immediate = false){

View File

@ -29,7 +29,7 @@ use pocketmine\Server;
use pocketmine\utils\ReversePriorityQueue;
class ServerScheduler{
public static $WORKERS = 3;
public static $WORKERS = 4;
/**
* @var ReversePriorityQueue<Task>
*/

@ -1 +1 @@
Subproject commit bf60d62c08353720ef0e65ae1c5c399c80e16b87
Subproject commit 9b0c3a587251d47cf63dbe0f9432126177b417a5