mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-09-07 02:08:21 +00:00
Fixed extremely stupid zero-length bug in BinaryStream
pls don't kill me 😢
This commit is contained in:
@ -57,19 +57,32 @@ class BinaryStream{
|
||||
return $this->buffer;
|
||||
}
|
||||
|
||||
public function get(int $len) : string{
|
||||
if($len < 0){
|
||||
$this->offset = strlen($this->buffer) - 1;
|
||||
return "";
|
||||
}elseif($len === 0){
|
||||
/**
|
||||
* @param int|bool $len
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function get($len) : string{
|
||||
if($len === true){
|
||||
$str = substr($this->buffer, $this->offset);
|
||||
$this->offset = strlen($this->buffer);
|
||||
return $str;
|
||||
}elseif($len < 0){
|
||||
$this->offset = strlen($this->buffer) - 1;
|
||||
return "";
|
||||
}elseif($len === 0){
|
||||
return "";
|
||||
}
|
||||
|
||||
return $len === 1 ? $this->buffer{$this->offset++} : substr($this->buffer, ($this->offset += $len) - $len, $len);
|
||||
}
|
||||
|
||||
public function getRemaining() : string{
|
||||
$str = substr($this->buffer, $this->offset);
|
||||
$this->offset = strlen($this->buffer);
|
||||
return $str;
|
||||
}
|
||||
|
||||
public function put(string $str){
|
||||
$this->buffer .= $str;
|
||||
}
|
||||
|
Reference in New Issue
Block a user