mirror of
https://github.com/oldminecraftcommunity/NostalgiaCore.git
synced 2026-11-20 11:39:43 +00:00
commit
1d6c8278f9
4 changed files with 33 additions and 24 deletions
|
|
@ -469,7 +469,7 @@ class Player{
|
|||
}
|
||||
|
||||
$packet->messageIndex = $this->counter[3]++;
|
||||
$packet->reliability = 2;
|
||||
$packet->reliability = RakNetInfo::RELIABILITY_RELIABLE;
|
||||
@$this->buffer->data[] = $packet;
|
||||
$this->bufferLen += 6 + $len;
|
||||
return [];
|
||||
|
|
@ -497,7 +497,7 @@ class Player{
|
|||
}
|
||||
|
||||
$packet->messageIndex = $this->counter[3]++;
|
||||
$packet->reliability = 2;
|
||||
$packet->reliability = RakNetInfo::RELIABILITY_RELIABLE;
|
||||
|
||||
$this->send($pk);
|
||||
$this->packetAlwaysRecoverQueue[$pk->seqNumber] = $pk;
|
||||
|
|
@ -519,7 +519,7 @@ class Player{
|
|||
|
||||
$pk = new UnknownPacket;
|
||||
$pk->packetID = $pk->pid();
|
||||
$pk->reliability = 3;
|
||||
$pk->reliability = RakNetInfo::RELIABILITY_RELIABLE_ORDERED;
|
||||
|
||||
$pk->orderChannel = Player::CHATMESSAGE_ORDER_CHANNEL;
|
||||
$pk->orderIndex = $orderIndex;
|
||||
|
|
@ -556,7 +556,7 @@ class Player{
|
|||
|
||||
$pk = new UnknownPacket;
|
||||
$pk->packetID = $pk->pid();
|
||||
$pk->reliability = 3;
|
||||
$pk->reliability = RakNetInfo::RELIABILITY_RELIABLE_ORDERED;
|
||||
|
||||
$pk->orderChannel = Player::BLOCKUPDATE_ORDER_CHANNEL;
|
||||
$pk->orderIndex = $orderIndex;
|
||||
|
|
@ -594,7 +594,7 @@ class Player{
|
|||
|
||||
$pk = new UnknownPacket;
|
||||
$pk->packetID = $pk->pid();
|
||||
$pk->reliability = 3;
|
||||
$pk->reliability = RakNetInfo::RELIABILITY_RELIABLE_ORDERED;
|
||||
|
||||
$pk->orderChannel = Player::ENTITY_ORDER_CHANNEL;
|
||||
$pk->orderIndex = $orderIndex;
|
||||
|
|
@ -634,7 +634,7 @@ class Player{
|
|||
|
||||
$pk = new UnknownPacket;
|
||||
$pk->packetID = $pk->pid();
|
||||
$pk->reliability = 2;
|
||||
$pk->reliability = RakNetInfo::RELIABILITY_RELIABLE;
|
||||
$pk->hasSplit = true;
|
||||
$pk->splitCount = $bufCount;
|
||||
$pk->splitID = $bigCnt;
|
||||
|
|
@ -671,7 +671,7 @@ class Player{
|
|||
|
||||
$pk = new UnknownPacket;
|
||||
$pk->packetID = $packet->pid();
|
||||
$pk->reliability = 2;
|
||||
$pk->reliability = RakNetInfo::RELIABILITY_RELIABLE;
|
||||
$pk->hasSplit = true;
|
||||
$pk->splitCount = $bufCount;
|
||||
$pk->splitID = $bigCnt;
|
||||
|
|
@ -1700,7 +1700,7 @@ class Player{
|
|||
}
|
||||
|
||||
$pk->messageIndex = $this->counter[3]++;
|
||||
$pk->reliability = 3;
|
||||
$pk->reliability = RakNetInfo::RELIABILITY_RELIABLE_ORDERED;
|
||||
$pk->orderChannel = Player::BLOCKUPDATE_ORDER_CHANNEL;
|
||||
$pk->orderIndex = $this->blockUpdateQueueOrderIndex++;
|
||||
@$this->blockUpdateQueue->data[] = $pk;
|
||||
|
|
@ -1745,7 +1745,7 @@ class Player{
|
|||
|
||||
$pk->messageIndex = $this->counter[3]++;
|
||||
|
||||
$pk->reliability = 3;
|
||||
$pk->reliability = RakNetInfo::RELIABILITY_RELIABLE_ORDERED;
|
||||
$pk->orderChannel = Player::ENTITY_ORDER_CHANNEL;
|
||||
$pk->orderIndex = $this->entityDataQueueOrderIndex++;
|
||||
@$this->entityDataQueue->data[] = $pk;
|
||||
|
|
@ -1854,7 +1854,7 @@ class Player{
|
|||
}
|
||||
if($motionSent){
|
||||
$motion->messageIndex = 0; //force 0 cuz reliability 0
|
||||
$motion->reliability = 1;
|
||||
$motion->reliability = RakNetInfo::RELIABILITY_UNRELIABLE_SEQUENCED;
|
||||
$motion->orderIndex = $this->entityDataQueueOrderIndex;
|
||||
$motion->orderChannel = self::ENTITY_ORDER_CHANNEL;
|
||||
$motion->seqIndex = $this->entityMovementQueueSeqIndex++;
|
||||
|
|
@ -1862,7 +1862,7 @@ class Player{
|
|||
}
|
||||
if($moveSent){
|
||||
$move->messageIndex = 0;
|
||||
$move->reliability = 1;
|
||||
$move->reliability = RakNetInfo::RELIABILITY_UNRELIABLE_SEQUENCED;
|
||||
$move->orderIndex = $this->entityDataQueueOrderIndex;
|
||||
$move->orderChannel = self::ENTITY_ORDER_CHANNEL;
|
||||
$move->seqIndex = $this->entityMovementQueueSeqIndex++;
|
||||
|
|
@ -1870,7 +1870,7 @@ class Player{
|
|||
}
|
||||
if($headSent){
|
||||
$headyaw->messageIndex = 0;
|
||||
$headyaw->reliability = 1;
|
||||
$headyaw->reliability = RakNetInfo::RELIABILITY_UNRELIABLE_SEQUENCED;
|
||||
$headyaw->orderIndex = $this->entityDataQueueOrderIndex;
|
||||
$headyaw->orderChannel = self::ENTITY_ORDER_CHANNEL;
|
||||
$headyaw->seqIndex = $this->entityMovementQueueSeqIndex++;
|
||||
|
|
@ -1985,7 +1985,7 @@ class Player{
|
|||
|
||||
if(($this->chatMessagesQueueLength + $len) >= $MTU) $this->sendChatBuffer();
|
||||
|
||||
$packet->reliability = 3;
|
||||
$packet->reliability = RakNetInfo::RELIABILITY_RELIABLE_ORDERED;
|
||||
$packet->messageIndex = $this->counter[3]++;
|
||||
$packet->orderChannel = Player::CHATMESSAGE_ORDER_CHANNEL;
|
||||
$packet->orderIndex = $this->chatMessagesOrderIndex++;
|
||||
|
|
|
|||
|
|
@ -99,21 +99,21 @@ class RakNetCodec{
|
|||
public static function encodeDataPacket(RakNetPacket $packet, RakNetDataPacket $pk){
|
||||
$packet->buffer .= chr(($pk->reliability << 5) | ($pk->hasSplit > 0 ? 0b00010000 : 0));
|
||||
$packet->buffer .= Utils::writeShort(strlen($pk->buffer) << 3);
|
||||
if($pk->reliability === 2
|
||||
or $pk->reliability === 3
|
||||
or $pk->reliability === 4
|
||||
or $pk->reliability === 6
|
||||
or $pk->reliability === 7){
|
||||
if($pk->reliability === RakNetInfo::RELIABILITY_RELIABLE
|
||||
or $pk->reliability === RakNetInfo::RELIABILITY_RELIABLE_ORDERED
|
||||
or $pk->reliability === RakNetInfo::RELIABILITY_RELIABLE_SEQUENCED
|
||||
or $pk->reliability === RakNetInfo::RELIABILITY_RELIABLE_WITHACKRECEIPT
|
||||
or $pk->reliability === RakNetInfo::RELIABILITY_RELIABLE_ORDERED_WITHACKRECEIPT){
|
||||
$packet->buffer .= Utils::writeLTriad($pk->messageIndex);
|
||||
}
|
||||
if($pk->reliability == 1 || $pk->reliability == 4){
|
||||
if($pk->reliability == RakNetInfo::RELIABILITY_UNRELIABLE_SEQUENCED || $pk->reliability == RakNetInfo::RELIABILITY_RELIABLE_SEQUENCED){
|
||||
$packet->buffer .= Utils::writeLTriad($pk->seqIndex);
|
||||
}
|
||||
|
||||
if($pk->reliability === 1
|
||||
or $pk->reliability === 3
|
||||
or $pk->reliability === 4
|
||||
or $pk->reliability === 7){
|
||||
if($pk->reliability === RakNetInfo::RELIABILITY_UNRELIABLE_SEQUENCED
|
||||
or $pk->reliability === RakNetInfo::RELIABILITY_RELIABLE_ORDERED
|
||||
or $pk->reliability === RakNetInfo::RELIABILITY_RELIABLE_SEQUENCED
|
||||
or $pk->reliability === RakNetInfo::RELIABILITY_RELIABLE_ORDERED_WITHACKRECEIPT){
|
||||
$packet->buffer .= Utils::writeLTriad($pk->orderIndex);
|
||||
$packet->buffer .= chr($pk->orderChannel);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@
|
|||
abstract class RakNetDataPacket extends stdClass{
|
||||
|
||||
public $buffer = b"";
|
||||
public $reliability = 0;
|
||||
public $reliability = RakNetInfo::RELIABILITY_UNRELIABLE;
|
||||
public $hasSplit = false;
|
||||
public $messageIndex;
|
||||
public $orderIndex;
|
||||
|
|
|
|||
|
|
@ -37,6 +37,15 @@ abstract class RakNetInfo{
|
|||
const NACK = 0xa0;
|
||||
const ACK = 0xc0;
|
||||
|
||||
const RELIABILITY_UNRELIABLE = 0;
|
||||
const RELIABILITY_UNRELIABLE_SEQUENCED = 1;
|
||||
const RELIABILITY_RELIABLE = 2;
|
||||
const RELIABILITY_RELIABLE_ORDERED = 3;
|
||||
const RELIABILITY_RELIABLE_SEQUENCED = 4;
|
||||
const RELIABILITY_UNRELIABLE_WITHACKRECEIPT = 5;
|
||||
const RELIABILITY_RELIABLE_WITHACKRECEIPT = 6;
|
||||
const RELIABILITY_RELIABLE_ORDERED_WITHACKRECEIPT = 7;
|
||||
|
||||
public static function isValid($pid){
|
||||
return match ((int)$pid) {
|
||||
RakNetInfo::UNCONNECTED_PING, RakNetInfo::UNCONNECTED_PING_OPEN_CONNECTIONS, RakNetInfo::OPEN_CONNECTION_REQUEST_1, RakNetInfo::OPEN_CONNECTION_REPLY_1, RakNetInfo::OPEN_CONNECTION_REQUEST_2, RakNetInfo::OPEN_CONNECTION_REPLY_2, RakNetInfo::INCOMPATIBLE_PROTOCOL_VERSION, RakNetInfo::UNCONNECTED_PONG, RakNetInfo::ADVERTISE_SYSTEM, RakNetInfo::DATA_PACKET_0, RakNetInfo::DATA_PACKET_1, RakNetInfo::DATA_PACKET_2, RakNetInfo::DATA_PACKET_3, RakNetInfo::DATA_PACKET_4, RakNetInfo::DATA_PACKET_5, RakNetInfo::DATA_PACKET_6, RakNetInfo::DATA_PACKET_7, RakNetInfo::DATA_PACKET_8, RakNetInfo::DATA_PACKET_9, RakNetInfo::DATA_PACKET_A, RakNetInfo::DATA_PACKET_B, RakNetInfo::DATA_PACKET_C, RakNetInfo::DATA_PACKET_D, RakNetInfo::DATA_PACKET_E, RakNetInfo::DATA_PACKET_F, RakNetInfo::NACK, RakNetInfo::ACK => true,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue