Get rid of some network-layer asserts

NEVER assert on user data. 🤦
This commit is contained in:
Dylan K. Taylor 2018-12-30 12:42:52 +00:00
parent 3f5e83a322
commit daf56e990b
2 changed files with 6 additions and 2 deletions

View File

@ -114,7 +114,9 @@ class ClientboundMapItemDataPacket extends DataPacket{
$this->yOffset = $this->getVarInt();
$count = $this->getUnsignedVarInt();
assert($count === $this->width * $this->height);
if($count !== $this->width * $this->height){
throw new \UnexpectedValueException("Expected colour count of " . ($this->height * $this->width) . " (height $this->height * width $this->width), got $count");
}
for($y = 0; $y < $this->height; ++$y){
for($x = 0; $x < $this->width; ++$x){

View File

@ -76,7 +76,9 @@ abstract class DataPacket extends NetworkBinaryStream{
protected function decodeHeader(){
$pid = $this->getUnsignedVarInt();
assert($pid === static::NETWORK_ID);
if($pid !== static::NETWORK_ID){
throw new \UnexpectedValueException("Expected " . static::NETWORK_ID . " for packet ID, got $pid");
}
}
/**