mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-06-11 05:55:33 +00:00
Packets bigger than the MTU are automagically split in different packets
This commit is contained in:
parent
b481c26839
commit
2c4a428698
@ -166,7 +166,11 @@ class Player{
|
|||||||
$z = $Z << 4;
|
$z = $Z << 4;
|
||||||
$y = $Y << 4;
|
$y = $Y << 4;
|
||||||
$this->level->useChunk($X, $Z, $this);
|
$this->level->useChunk($X, $Z, $this);
|
||||||
$this->directBigRawPacket(MC_CHUNK_DATA, Utils::writeInt($X) . Utils::writeInt($Z) . $this->level->getOrderedMiniChunk($X, $Z, $Y));
|
$this->dataPacket(MC_CHUNK_DATA, array(
|
||||||
|
"x" => $X,
|
||||||
|
"z" => $Z,
|
||||||
|
"data" => $this->level->getOrderedMiniChunk($X, $Z, $Y),
|
||||||
|
));
|
||||||
|
|
||||||
$tiles = $this->server->query("SELECT ID FROM tileentities WHERE spawnable = 1 AND level = '".$this->level->getName()."' AND x >= ".($x - 1)." AND x < ".($x + 17)." AND z >= ".($z - 1)." AND z < ".($z + 17)." AND y >= ".($y - 1)." AND y < ".($y + 17).";");
|
$tiles = $this->server->query("SELECT ID FROM tileentities WHERE spawnable = 1 AND level = '".$this->level->getName()."' AND x >= ".($x - 1)." AND x < ".($x + 17)." AND z >= ".($z - 1)." AND z < ".($z + 17)." AND y >= ".($y - 1)." AND y < ".($y + 17).";");
|
||||||
if($tiles !== false and $tiles !== true){
|
if($tiles !== false and $tiles !== true){
|
||||||
@ -1380,7 +1384,7 @@ class Player{
|
|||||||
$data["raw"] = Utils::writeShort(strlen($buf) << 3).strrev(Utils::writeTriad($this->counter[3]++)).$h.Utils::writeInt($i).$buf;
|
$data["raw"] = Utils::writeShort(strlen($buf) << 3).strrev(Utils::writeTriad($this->counter[3]++)).$h.Utils::writeInt($i).$buf;
|
||||||
$this->counter[3] %= 0x1000000;
|
$this->counter[3] %= 0x1000000;
|
||||||
$count = $this->counter[0]++;
|
$count = $this->counter[0]++;
|
||||||
if(count($this->recovery) >= 1024){
|
if(count($this->recovery) >= PLAYER_RECOVERY_BUFFER){
|
||||||
reset($this->recovery);
|
reset($this->recovery);
|
||||||
$k = key($this->recovery);
|
$k = key($this->recovery);
|
||||||
$this->recovery[$k] = null;
|
$this->recovery[$k] = null;
|
||||||
@ -1404,7 +1408,7 @@ class Player{
|
|||||||
$data["sendtime"] = microtime(true);
|
$data["sendtime"] = microtime(true);
|
||||||
if($count === false){
|
if($count === false){
|
||||||
$count = $this->counter[0]++;
|
$count = $this->counter[0]++;
|
||||||
if(count($this->recovery) >= 1024){
|
if(count($this->recovery) >= PLAYER_RECOVERY_BUFFER){
|
||||||
reset($this->recovery);
|
reset($this->recovery);
|
||||||
$k = key($this->recovery);
|
$k = key($this->recovery);
|
||||||
$this->recovery[$k] = null;
|
$this->recovery[$k] = null;
|
||||||
@ -1427,7 +1431,11 @@ class Player{
|
|||||||
}else{
|
}else{
|
||||||
$data = new CustomPacketHandler($id, "", $data, true);
|
$data = new CustomPacketHandler($id, "", $data, true);
|
||||||
$len = strlen($data->raw) + 1;
|
$len = strlen($data->raw) + 1;
|
||||||
$MTU = $this->MTU - 7;
|
$MTU = $this->MTU - 32;
|
||||||
|
if($len > $MTU){
|
||||||
|
$this->directBigRawPacket($id, $data->raw);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if((strlen($this->buffer) + $len) >= $MTU){
|
if((strlen($this->buffer) + $len) >= $MTU){
|
||||||
$this->sendBuffer();
|
$this->sendBuffer();
|
||||||
|
@ -30,4 +30,37 @@ define("SURVIVAL", 0);
|
|||||||
define("CREATIVE", 1);
|
define("CREATIVE", 1);
|
||||||
define("ADVENTURE", 2);
|
define("ADVENTURE", 2);
|
||||||
define("VIEW", 3);
|
define("VIEW", 3);
|
||||||
define("VIEWER", 3);
|
define("VIEWER", 3);
|
||||||
|
|
||||||
|
|
||||||
|
//Players
|
||||||
|
define("PLAYER_RECOVERY_BUFFER", 2048);
|
||||||
|
|
||||||
|
|
||||||
|
//Entities
|
||||||
|
define("ENTITY_PLAYER", 0);
|
||||||
|
|
||||||
|
define("ENTITY_MOB", 1);
|
||||||
|
define("MOB_CHICKEN", 10);
|
||||||
|
define("MOB_COW", 11);
|
||||||
|
define("MOB_PIG", 12);
|
||||||
|
define("MOB_SHEEP", 13);
|
||||||
|
|
||||||
|
define("MOB_ZOMBIE", 32);
|
||||||
|
define("MOB_CREEPER", 33);
|
||||||
|
define("MOB_SKELETON", 34);
|
||||||
|
define("MOB_SPIDER", 35);
|
||||||
|
define("MOB_PIGMAN", 36);
|
||||||
|
|
||||||
|
define("ENTITY_OBJECT", 2);
|
||||||
|
define("OBJECT_PAINTING", 83);
|
||||||
|
|
||||||
|
define("ENTITY_ITEM", 3);
|
||||||
|
|
||||||
|
|
||||||
|
//TileEntities
|
||||||
|
define("TILE_SIGN", "Sign");
|
||||||
|
define("TILE_CHEST", "Chest");
|
||||||
|
define("CHEST_SLOTS", 27);
|
||||||
|
define("TILE_FURNACE", "Furnace");
|
||||||
|
define("FURNACE_SLOTS", 3);
|
@ -25,26 +25,6 @@ the Free Software Foundation, either version 3 of the License, or
|
|||||||
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
define("ENTITY_PLAYER", 0);
|
|
||||||
|
|
||||||
define("ENTITY_MOB", 1);
|
|
||||||
define("MOB_CHICKEN", 10);
|
|
||||||
define("MOB_COW", 11);
|
|
||||||
define("MOB_PIG", 12);
|
|
||||||
define("MOB_SHEEP", 13);
|
|
||||||
|
|
||||||
define("MOB_ZOMBIE", 32);
|
|
||||||
define("MOB_CREEPER", 33);
|
|
||||||
define("MOB_SKELETON", 34);
|
|
||||||
define("MOB_SPIDER", 35);
|
|
||||||
define("MOB_PIGMAN", 36);
|
|
||||||
|
|
||||||
define("ENTITY_OBJECT", 2);
|
|
||||||
define("OBJECT_PAINTING", 83);
|
|
||||||
|
|
||||||
define("ENTITY_ITEM", 3);
|
|
||||||
|
|
||||||
class Entity extends Position{
|
class Entity extends Position{
|
||||||
public $age;
|
public $age;
|
||||||
public $air;
|
public $air;
|
||||||
|
@ -25,13 +25,6 @@ the Free Software Foundation, either version 3 of the License, or
|
|||||||
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
define("TILE_SIGN", "Sign");
|
|
||||||
define("TILE_CHEST", "Chest");
|
|
||||||
define("CHEST_SLOTS", 27);
|
|
||||||
define("TILE_FURNACE", "Furnace");
|
|
||||||
define("FURNACE_SLOTS", 3);
|
|
||||||
|
|
||||||
class TileEntity extends Position{
|
class TileEntity extends Position{
|
||||||
public $name;
|
public $name;
|
||||||
public $normal;
|
public $normal;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user