Moved network ids to constants, improved some entity methods, more performance

This commit is contained in:
Shoghi Cervantes
2015-05-30 23:59:24 +02:00
parent 32680843fa
commit 9e14435dbb
58 changed files with 197 additions and 436 deletions

View File

@ -25,7 +25,6 @@ use pocketmine\event\player\PlayerCreationEvent;
use pocketmine\network\protocol\DataPacket;
use pocketmine\network\protocol\Info as ProtocolInfo;
use pocketmine\network\protocol\Info;
use pocketmine\network\protocol\UnknownPacket;
use pocketmine\Player;
use pocketmine\Server;
use pocketmine\utils\MainLogger;
@ -136,8 +135,10 @@ class RakLibInterface implements ServerInstance, AdvancedSourceInterface{
try{
if($packet->buffer !== ""){
$pk = $this->getPacket($packet->buffer);
$pk->decode();
$this->players[$identifier]->handleDataPacket($pk);
if($pk !== null){
$pk->decode();
$this->players[$identifier]->handleDataPacket($pk);
}
}
}catch(\Exception $e){
if(\pocketmine\DEBUG > 1 and isset($pk)){
@ -216,7 +217,7 @@ class RakLibInterface implements ServerInstance, AdvancedSourceInterface{
$pk = $packet->__encapsulatedPacket;
}
if(!$immediate and !$needACK and $packet->pid() !== ProtocolInfo::BATCH_PACKET
if(!$immediate and !$needACK and $packet::NETWORK_ID !== ProtocolInfo::BATCH_PACKET
and Network::$BATCH_THRESHOLD >= 0
and strlen($packet->buffer) >= Network::$BATCH_THRESHOLD){
$this->server->batchPackets([$player], [$packet], true, $packet->getChannel());
@ -251,8 +252,7 @@ class RakLibInterface implements ServerInstance, AdvancedSourceInterface{
$pid = ord($buffer{0});
if(($data = $this->network->getPacket($pid)) === null){
$data = new UnknownPacket();
$data->packetID = $pid;
return null;
}
$data->setBuffer($buffer, 1);